compass-kb-validation 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- compass_kb_validation-1.0.0.dist-info/METADATA +305 -0
- compass_kb_validation-1.0.0.dist-info/RECORD +38 -0
- compass_kb_validation-1.0.0.dist-info/WHEEL +5 -0
- compass_kb_validation-1.0.0.dist-info/entry_points.txt +3 -0
- compass_kb_validation-1.0.0.dist-info/licenses/LICENSE +21 -0
- compass_kb_validation-1.0.0.dist-info/top_level.txt +3 -0
- discover_and_validate.py +184 -0
- ingestion_validation/__init__.py +8 -0
- ingestion_validation/config/__init__.py +428 -0
- ingestion_validation/corpus.py +113 -0
- ingestion_validation/live_dashboard.py +161 -0
- ingestion_validation/models/__init__.py +117 -0
- ingestion_validation/notifications.py +111 -0
- ingestion_validation/pipeline/__init__.py +128 -0
- ingestion_validation/providers/__init__.py +94 -0
- ingestion_validation/providers/graph.py +179 -0
- ingestion_validation/providers/source.py +141 -0
- ingestion_validation/providers/storage.py +238 -0
- ingestion_validation/providers/vectorstore.py +805 -0
- ingestion_validation/remediation.py +77 -0
- ingestion_validation/report/__init__.py +1040 -0
- ingestion_validation/report/_report_css.py +874 -0
- ingestion_validation/report/_report_js.py +477 -0
- ingestion_validation/report/export.py +126 -0
- ingestion_validation/trend_tracker.py +167 -0
- ingestion_validation/utils/__init__.py +106 -0
- ingestion_validation/validators/__init__.py +21 -0
- ingestion_validation/validators/api_upload.py +228 -0
- ingestion_validation/validators/base.py +25 -0
- ingestion_validation/validators/base_sparql.py +235 -0
- ingestion_validation/validators/graphdb_metadata.py +44 -0
- ingestion_validation/validators/neptune_metadata.py +55 -0
- ingestion_validation/validators/redis_chunks.py +542 -0
- ingestion_validation/validators/registry.py +150 -0
- ingestion_validation/validators/retrieval_quality.py +172 -0
- ingestion_validation/validators/s3_storage.py +236 -0
- ingestion_validation/validators/ui_document.py +155 -0
- run_validation.py +185 -0
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: compass-kb-validation
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Knowledge-base readiness validation for RAG & AI agents — config-driven, deterministic pipeline integrity checks.
|
|
5
|
+
Author: COMPASS
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/TestAutomationArchitect/compass
|
|
8
|
+
Project-URL: Repository, https://github.com/TestAutomationArchitect/compass
|
|
9
|
+
Project-URL: Issues, https://github.com/TestAutomationArchitect/compass/issues
|
|
10
|
+
Keywords: rag,knowledge-base,vector-database,data-validation,pipeline-testing,llm-infrastructure
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Topic :: Software Development :: Quality Assurance
|
|
17
|
+
Requires-Python: >=3.11
|
|
18
|
+
Description-Content-Type: text/markdown
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Requires-Dist: requests>=2.31.0
|
|
21
|
+
Requires-Dist: boto3>=1.34.0
|
|
22
|
+
Requires-Dist: pyyaml>=6.0.1
|
|
23
|
+
Requires-Dist: python-dotenv>=1.0.0
|
|
24
|
+
Requires-Dist: redis>=5.0.0
|
|
25
|
+
Provides-Extra: dashboard
|
|
26
|
+
Requires-Dist: fastapi>=0.104.0; extra == "dashboard"
|
|
27
|
+
Requires-Dist: uvicorn>=0.24.0; extra == "dashboard"
|
|
28
|
+
Provides-Extra: pdf
|
|
29
|
+
Requires-Dist: PyPDF2>=3.0.0; extra == "pdf"
|
|
30
|
+
Provides-Extra: ui
|
|
31
|
+
Requires-Dist: playwright>=1.40.0; extra == "ui"
|
|
32
|
+
Provides-Extra: qdrant
|
|
33
|
+
Requires-Dist: qdrant-client>=1.7.0; extra == "qdrant"
|
|
34
|
+
Provides-Extra: pgvector
|
|
35
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "pgvector"
|
|
36
|
+
Provides-Extra: pinecone
|
|
37
|
+
Requires-Dist: pinecone>=5.0.0; extra == "pinecone"
|
|
38
|
+
Provides-Extra: weaviate
|
|
39
|
+
Requires-Dist: weaviate-client>=4.5.0; extra == "weaviate"
|
|
40
|
+
Provides-Extra: azure
|
|
41
|
+
Requires-Dist: azure-storage-blob>=12.0.0; extra == "azure"
|
|
42
|
+
Requires-Dist: azure-identity>=1.15.0; extra == "azure"
|
|
43
|
+
Provides-Extra: gcs
|
|
44
|
+
Requires-Dist: google-cloud-storage>=2.10.0; extra == "gcs"
|
|
45
|
+
Provides-Extra: all
|
|
46
|
+
Requires-Dist: fastapi>=0.104.0; extra == "all"
|
|
47
|
+
Requires-Dist: uvicorn>=0.24.0; extra == "all"
|
|
48
|
+
Requires-Dist: PyPDF2>=3.0.0; extra == "all"
|
|
49
|
+
Requires-Dist: playwright>=1.40.0; extra == "all"
|
|
50
|
+
Requires-Dist: qdrant-client>=1.7.0; extra == "all"
|
|
51
|
+
Requires-Dist: psycopg[binary]>=3.1; extra == "all"
|
|
52
|
+
Requires-Dist: pinecone>=5.0.0; extra == "all"
|
|
53
|
+
Requires-Dist: weaviate-client>=4.5.0; extra == "all"
|
|
54
|
+
Requires-Dist: azure-storage-blob>=12.0.0; extra == "all"
|
|
55
|
+
Requires-Dist: azure-identity>=1.15.0; extra == "all"
|
|
56
|
+
Requires-Dist: google-cloud-storage>=2.10.0; extra == "all"
|
|
57
|
+
Provides-Extra: dev
|
|
58
|
+
Requires-Dist: pytest>=8.0.0; extra == "dev"
|
|
59
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
60
|
+
Requires-Dist: pyflakes>=3.0.0; extra == "dev"
|
|
61
|
+
Requires-Dist: pyright==1.1.409; extra == "dev"
|
|
62
|
+
Requires-Dist: bandit>=1.7.5; extra == "dev"
|
|
63
|
+
Requires-Dist: pip-audit>=2.6.0; extra == "dev"
|
|
64
|
+
Dynamic: license-file
|
|
65
|
+
|
|
66
|
+
# COMPASS — Knowledge-Base Readiness Validation for RAG & AI Agents
|
|
67
|
+
|
|
68
|
+
[](https://github.com/TestAutomationArchitect/compass/actions/workflows/ci.yml)
|
|
69
|
+
|
|
70
|
+
**COMPASS** — **COM**prehensive **P**ipeline **A**nalysis & **S**tructure **S**earch
|
|
71
|
+
|
|
72
|
+
A config-driven, **deterministic** framework that proves an AI/RAG knowledge base is correctly **built, intact, and retrievable** — *before* AI agents consume it. It's the integrity gate beneath answer-quality evaluation: not "are the answers good?" but **"is the knowledge base itself sound?"**
|
|
73
|
+
|
|
74
|
+
## What COMPASS Does
|
|
75
|
+
|
|
76
|
+
COMPASS validates a document's journey through your ingestion pipeline and verifies the resulting knowledge base is agent-ready. The pipeline is **declarative** — you choose which steps run, in what order, in YAML — and ships with these built-in steps:
|
|
77
|
+
|
|
78
|
+
```
|
|
79
|
+
API Upload → Object Storage → Knowledge Graph → Vector Store → Retrieval → UI Visibility
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
Enable only the steps your setup has (no object store? no graph? drop them), reorder them, or register your own. For each enabled step it deterministically checks, for example:
|
|
83
|
+
|
|
84
|
+
- **Ingestion** — the document was accepted and assigned an id
|
|
85
|
+
- **Object storage** — it persisted with the right content type, size, and integrity (S3, MinIO, R2, Azure Blob, GCS…)
|
|
86
|
+
- **Knowledge graph** — required metadata predicates are present and well-formed (GraphDB, Neptune, Neo4j…)
|
|
87
|
+
- **Vector store** — chunks exist with valid embeddings, correct dimensions/metric, sane ordering/overlap, no cross-document contamination (Redis, Qdrant, Pinecone, pgvector…) — **28 toggleable checks**
|
|
88
|
+
- **Retrieval** — the document's own content is actually retrievable (recall@K, MRR — informational)
|
|
89
|
+
- **UI visibility** — it surfaces in the end-user application
|
|
90
|
+
|
|
91
|
+
Two modes: **live** validation as documents are ingested, and **post-hoc discovery** of a corpus that's already loaded.
|
|
92
|
+
|
|
93
|
+
> Scope note: COMPASS validates *pipeline & data integrity*. It does **not** judge answer quality — that's the evaluation layer's job. COMPASS is the gate that runs first.
|
|
94
|
+
|
|
95
|
+
## Key Features
|
|
96
|
+
|
|
97
|
+
✅ **Declarative pipeline** — choose/reorder/extend steps in YAML; no fixed shape
|
|
98
|
+
✅ **Config-Driven** — zero code changes per project; all customization in YAML
|
|
99
|
+
✅ **Pluggable backends** — storage / vector store / knowledge graph via a provider registry (one file to add a vendor)
|
|
100
|
+
✅ **Pluggable steps** — register custom validators in a step registry; the report adapts automatically
|
|
101
|
+
✅ **Deterministic & cheap** — structural/byte/schema checks, no LLM, CI-gateable
|
|
102
|
+
✅ **Interactive reporting** — self-contained HTML dashboard + JSON + JUnit XML
|
|
103
|
+
✅ **Trend Tracking** — SQLite historical performance analysis
|
|
104
|
+
✅ **Notifications** — Slack/Teams webhooks for alerts
|
|
105
|
+
✅ **Parallel Execution** — process many documents concurrently
|
|
106
|
+
✅ **Graceful Degradation** — non-critical failures don't crash the pipeline
|
|
107
|
+
|
|
108
|
+
## Quick Start
|
|
109
|
+
|
|
110
|
+
Install the package (core deps only; add extras per backend — see below):
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
pip install compass-kb-validation
|
|
114
|
+
# backends/features on demand, e.g.:
|
|
115
|
+
pip install "compass-kb-validation[qdrant,pgvector]"
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
This installs two commands: `compass-validate` (live) and `compass-discover` (post-hoc).
|
|
119
|
+
Create a project config (`config/projects/<name>.yaml`) and, for live validation,
|
|
120
|
+
a `test_data/<name>.yaml` listing the documents to push. Then:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Live ingestion — validate documents as they're uploaded through your API
|
|
124
|
+
compass-validate --project my-kb --output-format all
|
|
125
|
+
|
|
126
|
+
# Post-hoc discovery — validate a knowledge base that's already populated
|
|
127
|
+
compass-discover --project my-kb --include-retrieval
|
|
128
|
+
|
|
129
|
+
# Validate connectivity/config only (no backends hit)
|
|
130
|
+
compass-validate --project my-kb --dry-run
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> From source instead of PyPI: `git clone … && cd compass && pip install -e ".[all]"`.
|
|
134
|
+
> Releases are published via [PUBLISHING.md](PUBLISHING.md).
|
|
135
|
+
|
|
136
|
+
Reports are written to `reports/` (HTML dashboard + JSON + JUnit XML). Add
|
|
137
|
+
`--live` to open a real-time progress dashboard, `--trends` to record history,
|
|
138
|
+
`--parallel` for concurrency.
|
|
139
|
+
|
|
140
|
+
### Try it locally (no cloud needed)
|
|
141
|
+
|
|
142
|
+
A self-contained Docker stack runs the full pipeline against MinIO + Redis Stack +
|
|
143
|
+
a mock ingestion API — see **[integration/README.md](integration/README.md)**.
|
|
144
|
+
|
|
145
|
+
## Project Structure
|
|
146
|
+
|
|
147
|
+
```
|
|
148
|
+
compass/
|
|
149
|
+
├── run_validation.py # Entry point — live ingestion validation
|
|
150
|
+
├── discover_and_validate.py # Entry point — post-hoc discovery
|
|
151
|
+
├── ingestion_validation/ # Main package
|
|
152
|
+
│ ├── models/ # StepResult / PipelineResult (stdlib dataclasses)
|
|
153
|
+
│ ├── config/ # Layered YAML config + typed Settings
|
|
154
|
+
│ ├── utils/ # Run-id, logging, polling w/ backoff
|
|
155
|
+
│ ├── providers/ # Pluggable backends via a registry:
|
|
156
|
+
│ │ ├── storage.py # object storage (S3-family…)
|
|
157
|
+
│ │ ├── vectorstore.py # vector store (Redis/RediSearch…)
|
|
158
|
+
│ │ ├── graph.py # knowledge graph (SPARQL, Neptune…)
|
|
159
|
+
│ │ └── source.py # document discovery (storage|index|manifest)
|
|
160
|
+
│ ├── validators/ # BaseValidator + step registry + the steps
|
|
161
|
+
│ │ └── registry.py # declarative pipeline (StepSpec registry)
|
|
162
|
+
│ ├── pipeline/ # Orchestrator (context propagation, halting)
|
|
163
|
+
│ ├── report/ # Self-contained HTML dashboard + JSON/JUnit
|
|
164
|
+
│ ├── corpus.py # Corpus-level KB readiness analysis
|
|
165
|
+
│ ├── live_dashboard.py # FastAPI + SSE real-time dashboard
|
|
166
|
+
│ ├── notifications.py # Slack / Teams webhooks
|
|
167
|
+
│ └── trend_tracker.py # SQLite historical trends
|
|
168
|
+
├── config/{base.yaml, projects/_template.yaml}
|
|
169
|
+
├── test_data/_template.yaml # Documents to validate (live mode)
|
|
170
|
+
├── integration/ # Local Docker integration stack
|
|
171
|
+
├── tests/ # Unit tests (backends faked — no live services)
|
|
172
|
+
└── reports/ # Generated reports (gitignored)
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
## Documentation
|
|
176
|
+
|
|
177
|
+
- **[ARCHITECTURE.md](ARCHITECTURE.md)** — how COMPASS is built: layers, data flow, the registries, the two run modes, extension points
|
|
178
|
+
- **[EXTENDING-BACKENDS.md](EXTENDING-BACKENDS.md)** — add a new backend (storage/vector/graph/source) or a new pipeline step
|
|
179
|
+
- **[integration/README.md](integration/README.md)** — run the full pipeline locally on Docker
|
|
180
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) · [SECURITY.md](SECURITY.md)
|
|
181
|
+
|
|
182
|
+
## Configuration
|
|
183
|
+
|
|
184
|
+
All behaviour lives in YAML; credentials are referenced by **environment-variable
|
|
185
|
+
name** and resolved at runtime (never stored in config). `config/base.yaml` holds
|
|
186
|
+
shared defaults; each `config/projects/<name>.yaml` overlays only what differs and
|
|
187
|
+
selects a `dev`/`staging`/`prod` environment block.
|
|
188
|
+
|
|
189
|
+
```yaml
|
|
190
|
+
# config/projects/my-kb.yaml
|
|
191
|
+
display_name: "My Knowledge Base"
|
|
192
|
+
|
|
193
|
+
# Declarative pipeline — choose which steps run, in what order (registry keys).
|
|
194
|
+
# Omit to use the full default pipeline.
|
|
195
|
+
pipeline:
|
|
196
|
+
steps: [api_upload, s3_storage, redis_chunks, retrieval_quality]
|
|
197
|
+
critical_steps: ["API Upload", "S3 Storage"] # failure here halts the run
|
|
198
|
+
|
|
199
|
+
# Where post-hoc discovery finds documents: storage | vectorstore | manifest
|
|
200
|
+
discovery:
|
|
201
|
+
provider: vectorstore # enumerate the KB straight from the index
|
|
202
|
+
|
|
203
|
+
environments:
|
|
204
|
+
dev:
|
|
205
|
+
api:
|
|
206
|
+
base_url_env: API_BASE_URL # env-var NAME, not the value
|
|
207
|
+
graphql_mutation: |
|
|
208
|
+
mutation ($file: Upload!, $metadata: JSON) { uploadDocument(file:$file, metadata:$metadata){ status document_id } }
|
|
209
|
+
s3:
|
|
210
|
+
provider: s3 # s3 | minio | r2 | azure_blob | gcs …
|
|
211
|
+
bucket_name: my-documents
|
|
212
|
+
prefix: knowledge-base/
|
|
213
|
+
redis:
|
|
214
|
+
provider: redis # redis | qdrant | pinecone | pgvector …
|
|
215
|
+
search_index: my_embeddings
|
|
216
|
+
expected_embedding_dim: 1536
|
|
217
|
+
expected_distance_metric: COSINE
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Advanced Usage
|
|
221
|
+
|
|
222
|
+
### Add a custom pipeline step
|
|
223
|
+
|
|
224
|
+
Steps are declarative — register a validator and reference it in `pipeline.steps`:
|
|
225
|
+
|
|
226
|
+
```python
|
|
227
|
+
from ingestion_validation.validators.base import BaseValidator
|
|
228
|
+
from ingestion_validation.validators.registry import register_step, StepSpec
|
|
229
|
+
from ingestion_validation.models import StepResult, StepStatus
|
|
230
|
+
|
|
231
|
+
class PiiRedactionValidator(BaseValidator):
|
|
232
|
+
step_name = "PII Redaction"
|
|
233
|
+
def __init__(self, config): self.config = config
|
|
234
|
+
def validate(self, context: dict) -> StepResult:
|
|
235
|
+
return StepResult(self.step_name, StepStatus.PASSED, "no PII leaked")
|
|
236
|
+
|
|
237
|
+
register_step(StepSpec(
|
|
238
|
+
key="pii_redaction", name="PII Redaction",
|
|
239
|
+
factory=lambda settings, shared: PiiRedactionValidator(settings.s3),
|
|
240
|
+
abbr="PII", order=25,
|
|
241
|
+
))
|
|
242
|
+
# then: pipeline.steps: [api_upload, pii_redaction, redis_chunks]
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
The orchestrator, live dashboard, and HTML report adapt automatically. See
|
|
246
|
+
**[EXTENDING-BACKENDS.md](EXTENDING-BACKENDS.md)** for adding backends too.
|
|
247
|
+
|
|
248
|
+
### CI/CD integration — the readiness gate
|
|
249
|
+
|
|
250
|
+
COMPASS is built to run **before** your agents or eval consume the knowledge
|
|
251
|
+
base: wire it into the pipeline that publishes the KB and fail the build when
|
|
252
|
+
the KB is not retrieval-ready. Every entry point returns a CI-friendly exit
|
|
253
|
+
code — **0 = gate passed, 1 = gate failed, 2 = config error** — and emits JUnit
|
|
254
|
+
XML for any CI system.
|
|
255
|
+
|
|
256
|
+
**Gate strictness** (discovery mode) is yours to choose:
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
# Strictest: any failed document fails the build (default)
|
|
260
|
+
compass-discover --project my-kb
|
|
261
|
+
|
|
262
|
+
# Tolerate a few failures: require >= 95% of documents to pass
|
|
263
|
+
compass-discover --project my-kb --fail-under 95
|
|
264
|
+
|
|
265
|
+
# Also require the corpus to be READY (completeness/coverage/dedup verdict)
|
|
266
|
+
compass-discover --project my-kb --require-ready
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
**GitHub Actions** — drop the reusable action into your KB pipeline:
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
# .github/workflows/kb-readiness.yml
|
|
273
|
+
jobs:
|
|
274
|
+
kb-readiness:
|
|
275
|
+
runs-on: ubuntu-latest
|
|
276
|
+
steps:
|
|
277
|
+
- uses: actions/checkout@v4 # your repo holds config/projects/<name>.yaml
|
|
278
|
+
- uses: TestAutomationArchitect/compass@v1
|
|
279
|
+
with:
|
|
280
|
+
project: my-kb
|
|
281
|
+
require-ready: "true" # block promotion unless READY
|
|
282
|
+
# fail-under: "95" # ...or tolerate a bounded failure rate
|
|
283
|
+
env:
|
|
284
|
+
REDIS_HOST: ${{ secrets.REDIS_HOST }} # config references env-var names; supply them here
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
A full example you can copy is in **[examples/kb-readiness.yml](examples/kb-readiness.yml)**.
|
|
288
|
+
|
|
289
|
+
**Container** — no Python setup needed; works in any CI or a self-hosted runner:
|
|
290
|
+
|
|
291
|
+
```bash
|
|
292
|
+
docker build -t compass:latest .
|
|
293
|
+
docker run --rm -v "$PWD:/work" --env-file .env \
|
|
294
|
+
compass:latest compass-discover --project my-kb --require-ready
|
|
295
|
+
```
|
|
296
|
+
|
|
297
|
+
## Applicable Domains
|
|
298
|
+
|
|
299
|
+
Enterprise document management · legal/compliance · healthcare · financial
|
|
300
|
+
research · customer-support KBs · internal wikis · e-commerce catalogs · academic
|
|
301
|
+
repositories — any RAG/agent knowledge base built from a document pipeline.
|
|
302
|
+
|
|
303
|
+
## License
|
|
304
|
+
|
|
305
|
+
MIT License — see [LICENSE](LICENSE).
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
discover_and_validate.py,sha256=vwiBA2HCCu-judb8wDTcXvmV8WRGuYDTLm2BD4pvXes,8551
|
|
2
|
+
run_validation.py,sha256=HNUlQHRV6mXIp9TK3_N3j3fSXnQAM1XUneeJj5eHV3A,7475
|
|
3
|
+
compass_kb_validation-1.0.0.dist-info/licenses/LICENSE,sha256=AX0mhitXCN2WT51Z0Kjs20MuBLcKzyFKGlBBtHpzEyE,1077
|
|
4
|
+
ingestion_validation/__init__.py,sha256=1sLkwhuyn9XugsH1LrzOEs6tC8uMUqZQfJmxd5Zjb_I,287
|
|
5
|
+
ingestion_validation/corpus.py,sha256=j-kTjOsDbYmfUa7gtyf__zJKgTKykT7JjOor63mbOOs,4386
|
|
6
|
+
ingestion_validation/live_dashboard.py,sha256=OUW2ZuF_sXdD9GI4RLZYFw98ZpKn2oCzBp2jWv1JGX4,6799
|
|
7
|
+
ingestion_validation/notifications.py,sha256=jSIbT1s8S9y5Hx4TLECE5MuGUdmzWOdlgyFmxvgckbw,3881
|
|
8
|
+
ingestion_validation/remediation.py,sha256=_drCAmtsMiE4OXGF2truNWl6KATvO43vX9UUitt6GEM,4591
|
|
9
|
+
ingestion_validation/trend_tracker.py,sha256=ncAU7U6rlfCYYlpZNLiVzUKf-I2WsWyjW-HwQXbMNQA,6720
|
|
10
|
+
ingestion_validation/config/__init__.py,sha256=TSo01o5pcmZ0bKU8GoZvHQeUkuI1ojasSVypTW88fnU,15752
|
|
11
|
+
ingestion_validation/models/__init__.py,sha256=ooJvC1lEicE0Y9Xqj9VWpPMjJCU4tsuf5_7PXe8f4uc,3814
|
|
12
|
+
ingestion_validation/pipeline/__init__.py,sha256=PZjXg93NE-Pp05sJf69_TP1Vwqm-nibj9FYFXc-P5Ik,5474
|
|
13
|
+
ingestion_validation/providers/__init__.py,sha256=4KLw23ve_XsePegY1b510l8iFun5gs4sESoHeY-upis,3285
|
|
14
|
+
ingestion_validation/providers/graph.py,sha256=y_rQfUOT5jBpYtrl9r-cZ18b8p_GdxcrekklLsmRWmY,6398
|
|
15
|
+
ingestion_validation/providers/source.py,sha256=maK7uV4wfN3VYusSObw6c0ooh2puHkW7cs8mED8YUxA,5848
|
|
16
|
+
ingestion_validation/providers/storage.py,sha256=us_q1U678dFeCOQau-7asv7LmxquoEM7kUQCKJ5r8no,8938
|
|
17
|
+
ingestion_validation/providers/vectorstore.py,sha256=qUFSkaOmV6obAFUP1JcF-US9-OrWDT0cXg_KaxuhTGw,33305
|
|
18
|
+
ingestion_validation/report/__init__.py,sha256=wkmkuKnPADdINqbedcC-IsRkx851g_X8jm2GyAp733I,64344
|
|
19
|
+
ingestion_validation/report/_report_css.py,sha256=tZN840yp_TsUMkgpkQaCQ9LL9ExFYJKBGEKBwvghX_M,35427
|
|
20
|
+
ingestion_validation/report/_report_js.py,sha256=SE3N0epDcXgDMnxgBdi5KAcu7JlhM-XfqheEPnbtluM,19588
|
|
21
|
+
ingestion_validation/report/export.py,sha256=zqnEsni94jxs5qA2oYKD4OucIPEZuQYqtdlQZ6LYMCY,4280
|
|
22
|
+
ingestion_validation/utils/__init__.py,sha256=6x1_weVXPjKPtmIJYNuBEStr_7dpNMcaxi5fnW1J9BE,3161
|
|
23
|
+
ingestion_validation/validators/__init__.py,sha256=qaJw5YmGVElKQU02GYZtdcGdzsVD-M9MhjV85BOXHsQ,898
|
|
24
|
+
ingestion_validation/validators/api_upload.py,sha256=cXIb0jUzIcI1knIbYl7I55yGhNepp00T1OtDWTt9iN0,8991
|
|
25
|
+
ingestion_validation/validators/base.py,sha256=5ysAKz74c1NrNe5m4XwqHX1dwTJ_-iygFIJ6Q6hv0Ts,849
|
|
26
|
+
ingestion_validation/validators/base_sparql.py,sha256=-VE6G2_9CnptULgSwLDeA03Z43UevCOKX8nMqOY24Nk,10830
|
|
27
|
+
ingestion_validation/validators/graphdb_metadata.py,sha256=ZVAkWbpsuaC1PLdaXtyXE2oGDhHN3_GdI_zycwrJTbA,1762
|
|
28
|
+
ingestion_validation/validators/neptune_metadata.py,sha256=cLnnat_R-dYDsDRNlNZxHtr_DFj1XOEn99SQCk-fAT0,2192
|
|
29
|
+
ingestion_validation/validators/redis_chunks.py,sha256=yo1l1ijgYvFS7vqD4FbraqnAo_laAfJH4KhZ--kovJs,27783
|
|
30
|
+
ingestion_validation/validators/registry.py,sha256=cBRybiGEKRLqCbTOrroQ5_q-6k-kDcogPyNZOSoULI0,6594
|
|
31
|
+
ingestion_validation/validators/retrieval_quality.py,sha256=Vsbmy62nafnXy6zMWjaMrMdJ8q9v2hg2lCmEfrmlhiU,7662
|
|
32
|
+
ingestion_validation/validators/s3_storage.py,sha256=acMxFgIOl-3pHNgQA8K3rQ9RWhw_14jWqOXfUN8npKY,10268
|
|
33
|
+
ingestion_validation/validators/ui_document.py,sha256=0xS6qVidpzi3vPCAUL9aFdFNr_QJsIN9IxNzR8I6Rx8,7318
|
|
34
|
+
compass_kb_validation-1.0.0.dist-info/METADATA,sha256=_jC78Lkb5B86Y-DCuUvUgB4dHUCx9pqWY5CuY0-XYng,14183
|
|
35
|
+
compass_kb_validation-1.0.0.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
|
|
36
|
+
compass_kb_validation-1.0.0.dist-info/entry_points.txt,sha256=t_DKfJzRTwqnae8hMcOwxY-okVg4F144Nr393cxFvYk,103
|
|
37
|
+
compass_kb_validation-1.0.0.dist-info/top_level.txt,sha256=Hx3kAZme27zH7yk0N6UcPoD9hn6xl5ZinwGDmq6olJU,58
|
|
38
|
+
compass_kb_validation-1.0.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 COMPASS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
discover_and_validate.py
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""COMPASS — post-hoc discovery & validation entry point.
|
|
3
|
+
|
|
4
|
+
Scans object storage for existing documents and validates their vector-store
|
|
5
|
+
chunks (and optionally graph metadata / retrieval quality) without re-ingesting.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import sys
|
|
12
|
+
|
|
13
|
+
try:
|
|
14
|
+
from dotenv import load_dotenv
|
|
15
|
+
except Exception: # pragma: no cover
|
|
16
|
+
load_dotenv = None # type: ignore
|
|
17
|
+
|
|
18
|
+
from ingestion_validation.config import load_settings
|
|
19
|
+
from ingestion_validation.pipeline import IngestionPipeline
|
|
20
|
+
from ingestion_validation.providers import get_adapter
|
|
21
|
+
from ingestion_validation.report import export_json, export_junit, generate_batch_dashboard
|
|
22
|
+
from ingestion_validation.utils import configure_logging, new_run_id
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
EXIT_OK, EXIT_GATE_FAILED, EXIT_CONFIG = 0, 1, 2
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def parse_args(argv=None) -> argparse.Namespace:
|
|
29
|
+
p = argparse.ArgumentParser(description="Discover storage documents and validate vector chunks")
|
|
30
|
+
p.add_argument("--project", required=True, help="Project name")
|
|
31
|
+
p.add_argument("--env", default="dev", help="Environment")
|
|
32
|
+
p.add_argument("--folder", help="Filter to a specific storage subfolder")
|
|
33
|
+
p.add_argument("--limit", type=int, help="Max documents to validate")
|
|
34
|
+
p.add_argument("--dry-run", action="store_true", help="List documents without validating")
|
|
35
|
+
p.add_argument("--output-format", choices=["html", "json", "junit", "all"], default="html")
|
|
36
|
+
p.add_argument("--include-graphdb", action="store_true", help="Also validate graph metadata")
|
|
37
|
+
p.add_argument("--include-retrieval", action="store_true", help="Also run retrieval quality")
|
|
38
|
+
p.add_argument("--no-trends", action="store_true", help="Do not record/report historical trends (on by default)")
|
|
39
|
+
# Gate strictness (for CI). Default gate: fail if any document fails.
|
|
40
|
+
p.add_argument("--fail-under", type=float, metavar="PCT",
|
|
41
|
+
help="Fail unless the document pass-rate is >= PCT (0-100). "
|
|
42
|
+
"Replaces the default 'fail on any failure' rule.")
|
|
43
|
+
p.add_argument("--require-ready", action="store_true",
|
|
44
|
+
help="Also fail unless the corpus readiness verdict is READY.")
|
|
45
|
+
return p.parse_args(argv)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def gate_failed(passed: int, total: int, verdict: str, fail_under: float | None,
|
|
49
|
+
require_ready: bool) -> tuple[bool, str]:
|
|
50
|
+
"""Decide whether the readiness gate fails, and why.
|
|
51
|
+
|
|
52
|
+
Returns (failed, reason). The gate is the product's contract with a CI
|
|
53
|
+
pipeline: a non-zero exit blocks promotion of a knowledge base that is not
|
|
54
|
+
retrieval-ready. Strictness is caller-controlled:
|
|
55
|
+
* default -- fail if any document failed validation
|
|
56
|
+
* --fail-under PCT -- fail if pass-rate < PCT (tolerates a few failures)
|
|
57
|
+
* --require-ready -- additionally fail if the corpus verdict != READY
|
|
58
|
+
"""
|
|
59
|
+
rate = (passed / total * 100.0) if total else 100.0
|
|
60
|
+
if fail_under is not None:
|
|
61
|
+
if rate < fail_under:
|
|
62
|
+
return True, f"pass-rate {rate:.1f}% < required {fail_under:.1f}%"
|
|
63
|
+
elif passed < total:
|
|
64
|
+
return True, f"{total - passed} document(s) failed validation"
|
|
65
|
+
if require_ready and verdict != "READY":
|
|
66
|
+
return True, f"corpus readiness verdict is {verdict} (READY required)"
|
|
67
|
+
return False, "all gate conditions met"
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
def _record_trends(results: list[dict], project: str, environment: str, run_id: str,
|
|
71
|
+
mode: str, disabled: bool) -> list[dict] | None:
|
|
72
|
+
"""Record this run to the trend DB and return this project's recent history."""
|
|
73
|
+
if disabled:
|
|
74
|
+
return None
|
|
75
|
+
from ingestion_validation.trend_tracker import record_run
|
|
76
|
+
rows = record_run(results, environment=environment, run_id=run_id, mode=mode, project=project)
|
|
77
|
+
print(" Trends recorded." if rows is not None else " (trend tracking skipped)")
|
|
78
|
+
return rows
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
def discover_documents(settings, folder_filter: str | None = None, limit: int | None = None) -> list[dict]:
|
|
82
|
+
"""Discover documents via the configured source provider.
|
|
83
|
+
|
|
84
|
+
``settings.discovery.provider`` selects where documents come from:
|
|
85
|
+
storage (object store), vectorstore (the index itself), manifest (a list
|
|
86
|
+
file), or any custom source. Records are normalised to carry document_id +
|
|
87
|
+
file_name (+ optional s3_key/s3_etag/s3_size/folder).
|
|
88
|
+
"""
|
|
89
|
+
source = get_adapter("source", settings.discovery.provider, settings=settings)
|
|
90
|
+
return source.discover(folder=folder_filter, limit=limit)
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
def validate_documents(settings, documents: list[dict], skip_steps: list[str]) -> list[dict]:
|
|
94
|
+
results = []
|
|
95
|
+
for i, doc in enumerate(documents, 1):
|
|
96
|
+
folder = doc.get("folder", "")
|
|
97
|
+
name = f"[{folder}] {doc['file_name']}" if folder else doc["file_name"]
|
|
98
|
+
print(f" [{i}/{len(documents)}] {name}")
|
|
99
|
+
# Pass through normalised identity + any storage hints the source provided.
|
|
100
|
+
extra = {"file_name": doc["file_name"], "document_id": doc["document_id"]}
|
|
101
|
+
for k in ("s3_key", "s3_etag", "s3_size"):
|
|
102
|
+
if doc.get(k) is not None:
|
|
103
|
+
extra[k] = doc[k]
|
|
104
|
+
pipeline = IngestionPipeline(settings, skip_steps=skip_steps)
|
|
105
|
+
result = pipeline.run(file_path="", extra_context=extra, case_name=name)
|
|
106
|
+
results.append({"name": name, "result": result})
|
|
107
|
+
return results
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def main(argv=None) -> int:
|
|
111
|
+
args = parse_args(argv)
|
|
112
|
+
configure_logging()
|
|
113
|
+
if load_dotenv:
|
|
114
|
+
load_dotenv()
|
|
115
|
+
run_id = new_run_id()
|
|
116
|
+
try:
|
|
117
|
+
settings = load_settings(project=args.project, env=args.env)
|
|
118
|
+
except Exception as exc: # noqa: BLE001 - surface config errors as exit 2 for CI
|
|
119
|
+
print(f" Config error: {exc}")
|
|
120
|
+
return EXIT_CONFIG
|
|
121
|
+
|
|
122
|
+
print("=" * 60)
|
|
123
|
+
print(f" Discovery Validation - {args.project} ({args.env})")
|
|
124
|
+
print(f" Run ID: {run_id}")
|
|
125
|
+
print("=" * 60)
|
|
126
|
+
|
|
127
|
+
documents = discover_documents(settings, folder_filter=args.folder, limit=args.limit)
|
|
128
|
+
print(f"\n Found {len(documents)} document(s)\n")
|
|
129
|
+
if not documents:
|
|
130
|
+
print(" No documents found. Check storage prefix and supported_extensions.")
|
|
131
|
+
return 0
|
|
132
|
+
|
|
133
|
+
if args.dry_run:
|
|
134
|
+
for doc in documents:
|
|
135
|
+
folder = doc.get("folder", "")
|
|
136
|
+
size = doc.get("s3_size")
|
|
137
|
+
tag = f"[{folder}] " if folder else ""
|
|
138
|
+
suffix = f" ({size:,} bytes)" if isinstance(size, int) and size else ""
|
|
139
|
+
print(f" {tag}{doc['file_name']}{suffix}")
|
|
140
|
+
return 0
|
|
141
|
+
|
|
142
|
+
skip_steps = ["API Upload", "UI Visibility"]
|
|
143
|
+
if not args.include_graphdb:
|
|
144
|
+
skip_steps += ["GraphDB Metadata", "Neptune Metadata"]
|
|
145
|
+
if not args.include_retrieval:
|
|
146
|
+
skip_steps.append("Retrieval Quality")
|
|
147
|
+
|
|
148
|
+
results = validate_documents(settings, documents, skip_steps=skip_steps)
|
|
149
|
+
|
|
150
|
+
# Corpus-level knowledge-base readiness (completeness, dedup, coverage).
|
|
151
|
+
from ingestion_validation.corpus import analyze_corpus
|
|
152
|
+
|
|
153
|
+
corpus = analyze_corpus(
|
|
154
|
+
documents, results,
|
|
155
|
+
expected_documents=settings.discovery.extra.get("expected_documents"),
|
|
156
|
+
expected_folders=settings.discovery.extra.get("expected_folders"),
|
|
157
|
+
)
|
|
158
|
+
print(f" KB readiness: {corpus['verdict']} ({corpus['passed']}/{corpus['total']} passed, "
|
|
159
|
+
f"{len(corpus['issues'])} issue(s))")
|
|
160
|
+
|
|
161
|
+
# Maintain historical trends (stdlib sqlite; on by default) and embed them in the report.
|
|
162
|
+
trend_rows = _record_trends(results, args.project, args.env, run_id, "Discovery", disabled=args.no_trends)
|
|
163
|
+
|
|
164
|
+
passed = sum(1 for r in results if r["result"].all_passed)
|
|
165
|
+
failed = len(results) - passed
|
|
166
|
+
base = f"reports/{args.project}-discovery-report"
|
|
167
|
+
if args.output_format in ("html", "all"):
|
|
168
|
+
print(f"\n HTML report: {generate_batch_dashboard(results, base + '.html', project=args.project, environment=args.env, run_id=run_id, trends=trend_rows, corpus=corpus, mode='Discovery')}")
|
|
169
|
+
if args.output_format in ("json", "all"):
|
|
170
|
+
print(f" JSON report: {export_json(results, base + '.json')}")
|
|
171
|
+
if args.output_format in ("junit", "all"):
|
|
172
|
+
print(f" JUnit report: {export_junit(results, base + '.xml')}")
|
|
173
|
+
|
|
174
|
+
failed_gate, reason = gate_failed(passed, len(results), corpus["verdict"],
|
|
175
|
+
args.fail_under, args.require_ready)
|
|
176
|
+
print("=" * 60)
|
|
177
|
+
print(f" Results: {passed} passed, {failed} failed ({len(results)} total)")
|
|
178
|
+
print(f" Gate: {'FAILED' if failed_gate else 'PASSED'} - {reason}")
|
|
179
|
+
print("=" * 60)
|
|
180
|
+
return EXIT_GATE_FAILED if failed_gate else EXIT_OK
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
if __name__ == "__main__":
|
|
184
|
+
sys.exit(main())
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"""COMPASS — Comprehensive Pipeline Analysis & Structure Search.
|
|
2
|
+
|
|
3
|
+
A config-driven framework for validating AI/RAG document ingestion pipelines
|
|
4
|
+
end-to-end: API upload -> object storage -> knowledge graph -> vector store ->
|
|
5
|
+
retrieval quality -> UI visibility.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
__version__ = "1.0.0"
|