compass-kb-validation 4.0.1__tar.gz → 4.0.2__tar.gz
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-4.0.1 → compass_kb_validation-4.0.2}/PKG-INFO +14 -3
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/README.md +13 -2
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/__init__.py +1 -1
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/benchmark.py +10 -3
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/check_catalog.py +11 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/cli.py +32 -19
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/config/__init__.py +23 -3
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/config_lint.py +14 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/content_fidelity.py +78 -6
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/corpus_health.py +47 -19
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/drift.py +20 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/grounding.py +8 -2
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/snapshot.py +14 -1
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/readiness.py +58 -2
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/grounding_report.py +5 -1
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/PKG-INFO +14 -3
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/SOURCES.txt +1 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/discover_and_validate.py +25 -4
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_content_fidelity.py +2 -2
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_discover_cli.py +6 -5
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_fidelity_precision.py +1 -1
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_grounding_rollup.py +2 -1
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_measurement_fixes.py +4 -3
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_readiness.py +3 -4
- compass_kb_validation-4.0.2/tests/test_v402_fixes.py +282 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/LICENSE +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/__main__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/alias.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/ask.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/baseline.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/chunk_coherence.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/chunk_eval.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/chunk_integrity.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/citation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/content_inspect.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/corpus.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/diagnostics.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/diff.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/embedding_drift.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/eval_enrich.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/eval_interop.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/evidence.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/grounding_diff.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/grounding_rollup.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/gt_lint.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/health.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/incremental.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/init_wizard.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/lineage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/live_dashboard.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/mcp_server.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/models/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/notifications.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/pipeline/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/profiler.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/provenance.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/embedding.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/extractor.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/graph.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/source.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/storage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/providers/vectorstore.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/quality_gate.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/remediation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/_report_css.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/_report_js.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/analysis.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/audit.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/export.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/report/shell.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/retrieval_analysis.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/simulate.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/text_match.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/text_probes.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/trend_tracker.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/utils/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/api_upload.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/base.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/base_sparql.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/cross_stage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/graphdb_metadata.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/neptune_metadata.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/redis_chunks.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/registry.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/retrieval_quality.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass/validators/s3_storage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/dependency_links.txt +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/entry_points.txt +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/requires.txt +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/compass_kb_validation.egg-info/top_level.txt +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/ingestion_validation/__init__.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/profile_kb.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/pyproject.toml +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/run_validation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/setup.cfg +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_alias.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_alias_disambiguation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_alias_temporal.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_alt_adapters.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_analysis_report.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_api_upload.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_ask.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_baseline.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_benchmark.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_calibrate_truth.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_check_catalog.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_chunk_eval.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_chunk_integrity.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_chunk_structure_checks.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_citation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_citation_levels.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_cli.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_cli_commands.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_compat_shim.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_config.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_config_lint.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_content_inspect.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_corpus.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_corpus_health.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_coverage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_coverage_and_drift_config.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_cross_stage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_diagnostics.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_diff.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_discovery_parallel.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_drift.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_embedding_contract.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_embedding_drift.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_eval_enrich.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_eval_interop.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_evidence.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_gate.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_graph_transport.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_graph_validators.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_grounding.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_grounding_report.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_health.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_incremental.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_init_wizard.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_lineage.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_manifest.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_mcp.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_migration.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_models.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_multi_index.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_neptune_bugfixes.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_neptune_bugfixes2.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_notifications.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_pipeline.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_profiler.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_providers.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_quality_gate.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_redis_chunks.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_registry.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_remediation.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_report_store_section.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_reporting.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_requirements_config.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_retrieval_assertions.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_retrieval_fields.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_retrieval_quality.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_review_hardening.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_run_cli.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_simulate.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_source_exclusions.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_source_verification.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_sources.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_storage_validator.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_trends.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_universal_concerns.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_utils.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_v4_defect_fixes.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_vector_fastpath.py +0 -0
- {compass_kb_validation-4.0.1 → compass_kb_validation-4.0.2}/tests/test_vectorstore_filters.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: compass-kb-validation
|
|
3
|
-
Version: 4.0.
|
|
3
|
+
Version: 4.0.2
|
|
4
4
|
Summary: Knowledge-base readiness validation for RAG & AI agents — config-driven, deterministic pipeline integrity checks.
|
|
5
5
|
Author: COMPASS
|
|
6
6
|
License: MIT
|
|
@@ -299,7 +299,7 @@ compass chunk-eval --project my-kb --sample 50 --strategy fixed:3000/200 --strat
|
|
|
299
299
|
|
|
300
300
|
# One verdict for the whole KB, composed from artifacts the commands above already wrote. See
|
|
301
301
|
# "KB readiness" below. No live connections. Exit 0 READY, 1 otherwise, 2 bad input.
|
|
302
|
-
compass readiness --
|
|
302
|
+
compass readiness --project my-kb # finds reports/my-kb-<stage>.json; or name each with a flag
|
|
303
303
|
# Do two environments hold the same KB? Documents missing either way, schema, e_tags that
|
|
304
304
|
# differ, pollution patterns, stale versions. Exits 0 no drift, 1 drift, 2 config error or could
|
|
305
305
|
# not compare: an environment that cannot be read is never reported as "no drift".
|
|
@@ -334,6 +334,7 @@ eval:
|
|
|
334
334
|
citation_source_key_fields: ["s3_key"] # chunk field holding the source object key
|
|
335
335
|
source_extractor: auto # auto | pymupdf | pdfplumber | pypdf | pdf_text
|
|
336
336
|
fidelity:
|
|
337
|
+
text_field: text # index field holding chunk text (not the eval file's)
|
|
337
338
|
normalization: aggressive # minimal | standard | aggressive
|
|
338
339
|
match: shingle # shingle | exact
|
|
339
340
|
coverage_min: {default: 0.90, quarterly: 0.97} # keyed by document_type
|
|
@@ -353,6 +354,12 @@ the source has pages with no text layer. A consistent page shift is reported onc
|
|
|
353
354
|
`eval.fidelity.page_tolerance` (default 1), `page_field`, `page_end_field` and `position_field`, or
|
|
354
355
|
turn it off with `chunk_integrity: false`.
|
|
355
356
|
|
|
357
|
+
Two outcomes are setup faults, never losses. A document whose chunks have no text in
|
|
358
|
+
`eval.fidelity.text_field` is not comparable, and the reason names the fields that do hold text.
|
|
359
|
+
A document where not one chunk traces to its source is `SOURCE_MISMATCH`: either the field or the
|
|
360
|
+
source key is wrong, or the store holds another document's text under that id. Neither is averaged
|
|
361
|
+
into coverage as a 0%. A snapshot that cannot be found is reported with the key it was looked for at.
|
|
362
|
+
|
|
356
363
|
Findings say what is missing, not who lost it, until you declare the extractor's own output. Any
|
|
357
364
|
extractor that writes JSON works: map its fields once, and each finding becomes `PIPELINE_DROP`,
|
|
358
365
|
`PIPELINE_ALTER` or `EXTRACTOR_MISS`.
|
|
@@ -380,7 +387,10 @@ eval:
|
|
|
380
387
|
[--project P] [--format console|json|html] [--output F]` reads JSON the other commands wrote and
|
|
381
388
|
returns READY, AT RISK or NOT READY, with a stage and an owner (ingestion, retrieval config,
|
|
382
389
|
generator) for every finding. A stage whose artifact is absent, or which measured nothing, is
|
|
383
|
-
**not examined** and caps the verdict at AT RISK: never READY by omission.
|
|
390
|
+
**not examined** and caps the verdict at AT RISK: never READY by omission. With `--project`, a stage
|
|
391
|
+
no flag names is read from `readiness.artifacts` (`{stage: path}`), then from
|
|
392
|
+
`reports/<project>-discovery-report.json` and `reports/<project>-<stage>.json` for `benchmark`,
|
|
393
|
+
`grounding`, `drift` and `fidelity`. A stage still missing names the command that writes it. `gate` means NOT READY,
|
|
384
394
|
`risk` means AT RISK, `advisory` is reported and changes nothing.
|
|
385
395
|
|
|
386
396
|
Every verdict carries `verified` / `unverifiable` / `not-checked` counts, and `discover` prints and
|
|
@@ -411,6 +421,7 @@ it changes no verdict.
|
|
|
411
421
|
| `fidelity_content_loss` | advisory | ingestion |
|
|
412
422
|
| `fidelity_numbers_missing` | advisory | ingestion |
|
|
413
423
|
| `fidelity_value_drift` | advisory | ingestion |
|
|
424
|
+
| `fidelity_source_mismatch` | risk | ingestion |
|
|
414
425
|
| `chunk_integrity_findings` | advisory | ingestion |
|
|
415
426
|
| `stale_versions`, `stale_versions_unchecked` | advisory | ingestion |
|
|
416
427
|
| `documents_within_threshold` | advisory | ingestion |
|
|
@@ -226,7 +226,7 @@ compass chunk-eval --project my-kb --sample 50 --strategy fixed:3000/200 --strat
|
|
|
226
226
|
|
|
227
227
|
# One verdict for the whole KB, composed from artifacts the commands above already wrote. See
|
|
228
228
|
# "KB readiness" below. No live connections. Exit 0 READY, 1 otherwise, 2 bad input.
|
|
229
|
-
compass readiness --
|
|
229
|
+
compass readiness --project my-kb # finds reports/my-kb-<stage>.json; or name each with a flag
|
|
230
230
|
# Do two environments hold the same KB? Documents missing either way, schema, e_tags that
|
|
231
231
|
# differ, pollution patterns, stale versions. Exits 0 no drift, 1 drift, 2 config error or could
|
|
232
232
|
# not compare: an environment that cannot be read is never reported as "no drift".
|
|
@@ -261,6 +261,7 @@ eval:
|
|
|
261
261
|
citation_source_key_fields: ["s3_key"] # chunk field holding the source object key
|
|
262
262
|
source_extractor: auto # auto | pymupdf | pdfplumber | pypdf | pdf_text
|
|
263
263
|
fidelity:
|
|
264
|
+
text_field: text # index field holding chunk text (not the eval file's)
|
|
264
265
|
normalization: aggressive # minimal | standard | aggressive
|
|
265
266
|
match: shingle # shingle | exact
|
|
266
267
|
coverage_min: {default: 0.90, quarterly: 0.97} # keyed by document_type
|
|
@@ -280,6 +281,12 @@ the source has pages with no text layer. A consistent page shift is reported onc
|
|
|
280
281
|
`eval.fidelity.page_tolerance` (default 1), `page_field`, `page_end_field` and `position_field`, or
|
|
281
282
|
turn it off with `chunk_integrity: false`.
|
|
282
283
|
|
|
284
|
+
Two outcomes are setup faults, never losses. A document whose chunks have no text in
|
|
285
|
+
`eval.fidelity.text_field` is not comparable, and the reason names the fields that do hold text.
|
|
286
|
+
A document where not one chunk traces to its source is `SOURCE_MISMATCH`: either the field or the
|
|
287
|
+
source key is wrong, or the store holds another document's text under that id. Neither is averaged
|
|
288
|
+
into coverage as a 0%. A snapshot that cannot be found is reported with the key it was looked for at.
|
|
289
|
+
|
|
283
290
|
Findings say what is missing, not who lost it, until you declare the extractor's own output. Any
|
|
284
291
|
extractor that writes JSON works: map its fields once, and each finding becomes `PIPELINE_DROP`,
|
|
285
292
|
`PIPELINE_ALTER` or `EXTRACTOR_MISS`.
|
|
@@ -307,7 +314,10 @@ eval:
|
|
|
307
314
|
[--project P] [--format console|json|html] [--output F]` reads JSON the other commands wrote and
|
|
308
315
|
returns READY, AT RISK or NOT READY, with a stage and an owner (ingestion, retrieval config,
|
|
309
316
|
generator) for every finding. A stage whose artifact is absent, or which measured nothing, is
|
|
310
|
-
**not examined** and caps the verdict at AT RISK: never READY by omission.
|
|
317
|
+
**not examined** and caps the verdict at AT RISK: never READY by omission. With `--project`, a stage
|
|
318
|
+
no flag names is read from `readiness.artifacts` (`{stage: path}`), then from
|
|
319
|
+
`reports/<project>-discovery-report.json` and `reports/<project>-<stage>.json` for `benchmark`,
|
|
320
|
+
`grounding`, `drift` and `fidelity`. A stage still missing names the command that writes it. `gate` means NOT READY,
|
|
311
321
|
`risk` means AT RISK, `advisory` is reported and changes nothing.
|
|
312
322
|
|
|
313
323
|
Every verdict carries `verified` / `unverifiable` / `not-checked` counts, and `discover` prints and
|
|
@@ -338,6 +348,7 @@ it changes no verdict.
|
|
|
338
348
|
| `fidelity_content_loss` | advisory | ingestion |
|
|
339
349
|
| `fidelity_numbers_missing` | advisory | ingestion |
|
|
340
350
|
| `fidelity_value_drift` | advisory | ingestion |
|
|
351
|
+
| `fidelity_source_mismatch` | risk | ingestion |
|
|
341
352
|
| `chunk_integrity_findings` | advisory | ingestion |
|
|
342
353
|
| `stale_versions`, `stale_versions_unchecked` | advisory | ingestion |
|
|
343
354
|
| `documents_within_threshold` | advisory | ingestion |
|
|
@@ -371,8 +371,8 @@ def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
|
|
|
371
371
|
result = score_one(retrieved, relevant, strategy.effective_k)
|
|
372
372
|
for metric, value in result.items():
|
|
373
373
|
scores[metric].append(value)
|
|
374
|
-
per_query.setdefault(cid, {"question": question,
|
|
375
|
-
"
|
|
374
|
+
per_query.setdefault(cid, {"question": question, "ground_truth": len(relevant),
|
|
375
|
+
"filtered": bool(filters)})[strategy.name] = {
|
|
376
376
|
"found": len([r for r in retrieved[:strategy.effective_k] if r in relevant]),
|
|
377
377
|
"recall": result["recall"], "mrr": result["mrr"]}
|
|
378
378
|
if errors and len(errors) == len(usable):
|
|
@@ -388,6 +388,10 @@ def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
|
|
|
388
388
|
})
|
|
389
389
|
|
|
390
390
|
filtered = sum(1 for row in usable if row[3])
|
|
391
|
+
# Named, not just counted: an unfiltered case scores against the whole corpus, so one of
|
|
392
|
+
# them can move the mean on its own and the reader needs to know which.
|
|
393
|
+
unfiltered = [str(row[0].get("case_id") or row[0].get("test_id") or row[1][:40])
|
|
394
|
+
for row in usable if not row[3]]
|
|
391
395
|
scored = [s for s in per_strategy if not s.get("skipped")]
|
|
392
396
|
def rank(row: dict) -> tuple:
|
|
393
397
|
return (row.get("ndcg") or 0, row.get("recall") or 0)
|
|
@@ -407,6 +411,7 @@ def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
|
|
|
407
411
|
"none-recorded" if not filtered else
|
|
408
412
|
"per-case" if filtered == len(usable) else "partial"),
|
|
409
413
|
"filtered_cases": filtered,
|
|
414
|
+
"unfiltered_cases": unfiltered if use_case_filters and filtered else [],
|
|
410
415
|
"match_mode": f"content ({MATCH_VERSION}, containment>={min_containment:g})"
|
|
411
416
|
if by_content else "page",
|
|
412
417
|
"method": ("binary-relevance IR metrics against the eval's own ground-truth chunks, "
|
|
@@ -508,8 +513,10 @@ def _filter_line(report: dict) -> str:
|
|
|
508
513
|
if mode == "per-case":
|
|
509
514
|
return f"Filters: each case's recorded filters applied ({n}/{total} cases)."
|
|
510
515
|
if mode == "partial":
|
|
516
|
+
names = report.get("unfiltered_cases") or []
|
|
517
|
+
shown = ", ".join(names[:5]) + (" ..." if len(names) > 5 else "")
|
|
511
518
|
return (f"Filters: recorded filters applied to {n}/{total} cases; the other "
|
|
512
|
-
f"{total - n} ran UNFILTERED.")
|
|
519
|
+
f"{total - n} ran UNFILTERED" + (f" ({shown})" if shown else "") + ".")
|
|
513
520
|
if mode == "disabled":
|
|
514
521
|
return ("Filters: UNFILTERED by request. If production filters, this understates what "
|
|
515
522
|
"production retrieves.")
|
|
@@ -486,6 +486,12 @@ _TEXT: dict[str, dict[str, tuple[str, str, str]]] = {
|
|
|
486
486
|
"Whether a figure the extractor produced survived, with its row's words intact.",
|
|
487
487
|
"The row reached the store with a different value, so a step rewrote it.",
|
|
488
488
|
"Inspect the transform after extraction, usually table conversion."),
|
|
489
|
+
"source_mismatch": (
|
|
490
|
+
"Whether a document's stored text and its source are the same text at all.",
|
|
491
|
+
"Not one chunk traces to the source. The comparison reads the wrong field or file, "
|
|
492
|
+
"or the store holds another document's text under this id.",
|
|
493
|
+
"Check eval.fidelity.text_field and eval.citation_source_key_fields, then the "
|
|
494
|
+
"document's chunks."),
|
|
489
495
|
"unverifiable": (
|
|
490
496
|
"Whether a document or page has text that can be compared at all.",
|
|
491
497
|
"Nothing was concluded: an image-only page, a garbled text layer or an unreadable "
|
|
@@ -536,6 +542,7 @@ _FIDELITY_TITLES = {
|
|
|
536
542
|
"content_loss": ("Content loss", "warn"),
|
|
537
543
|
"numbers_missing": ("Numbers missing", "warn"),
|
|
538
544
|
"value_drift": ("Value drift", "warn"),
|
|
545
|
+
"source_mismatch": ("Source mismatch", "warn"),
|
|
539
546
|
"unverifiable": ("Unverifiable document or page", "info"),
|
|
540
547
|
"wrong_page": ("Chunk on the wrong page", "warn"),
|
|
541
548
|
"altered": ("Chunk altered", "warn"),
|
|
@@ -639,6 +646,10 @@ def _category(stage: str, title: str, steps: tuple[str, ...]) -> str:
|
|
|
639
646
|
"""The report's own category for a check, so the catalogue and a report cannot disagree."""
|
|
640
647
|
if stage == "grounding":
|
|
641
648
|
return "Grounding"
|
|
649
|
+
if stage == "fidelity":
|
|
650
|
+
# Their titles ("Chunk altered", "Value drift") match no report pattern, so every one
|
|
651
|
+
# of them read "Other" though all of them ask whether the content survived.
|
|
652
|
+
return "Content Preservation"
|
|
642
653
|
from compass.report import _categorise
|
|
643
654
|
return _categorise(title, steps[0] if steps else "")
|
|
644
655
|
|
|
@@ -1934,6 +1934,18 @@ def cmd_grounding_audit(argv: list[str]) -> int:
|
|
|
1934
1934
|
total_cits = sum(r.citations.get("summary", {}).get("total_citations", 0) for r in results)
|
|
1935
1935
|
cit_sound = sum(r.citations.get("summary", {}).get("sound", 0) for r in results)
|
|
1936
1936
|
cit_checkable = sum(r.citations.get("summary", {}).get("checkable", 0) for r in results)
|
|
1937
|
+
if total_cits:
|
|
1938
|
+
# The headline is what was verified where it was cited, over every citation. A rate
|
|
1939
|
+
# over "checkable" read 100% beside 16 of 213 verified: the rest were weak term
|
|
1940
|
+
# matches and unverifiable claims, which that denominator leaves out.
|
|
1941
|
+
from compass.grounding_rollup import coverage_line, exclusion_lines, rollup as _rollup
|
|
1942
|
+
roll = _rollup(results)
|
|
1943
|
+
located = int(roll["verification"].get("verified", 0) or 0)
|
|
1944
|
+
print(f"\n Citation audit: {located} of {total_cits} citation(s) verified at the cited "
|
|
1945
|
+
f"location ({round(100.0 * located / total_cits, 1)}%).")
|
|
1946
|
+
print(f" all {total_cits}: {coverage_line(roll['verification'])}.")
|
|
1947
|
+
for line in exclusion_lines(roll["exclusions"]):
|
|
1948
|
+
print(f" {line}.")
|
|
1937
1949
|
if cit_checkable:
|
|
1938
1950
|
faultmix: dict[str, int] = {}
|
|
1939
1951
|
for r in results:
|
|
@@ -1947,10 +1959,9 @@ def cmd_grounding_audit(argv: list[str]) -> int:
|
|
|
1947
1959
|
cit_in_kb = sum(r.citations.get("summary", {}).get("kb_confirmed", 0)
|
|
1948
1960
|
for r in results)
|
|
1949
1961
|
in_kb_pct = round(100.0 * cit_in_kb / cit_checkable, 1)
|
|
1950
|
-
print(f"
|
|
1951
|
-
f"confirmed present in the KB ({in_kb_pct}%)
|
|
1952
|
-
|
|
1953
|
-
f"({acc}%).")
|
|
1962
|
+
print(f" of the {cit_checkable} checkable: {cit_sound} with no fault ({acc}%); "
|
|
1963
|
+
f"{cit_in_kb} confirmed present in the KB ({in_kb_pct}%), so a fault among "
|
|
1964
|
+
"those is retrieval or citation, not missing content.")
|
|
1954
1965
|
if faultmix:
|
|
1955
1966
|
print(" faults: " + ", ".join(f"{k} x{n}" for k, n in sorted(faultmix.items())))
|
|
1956
1967
|
# Graduated tiers: how much of the shortfall is near-misses vs nothing-found.
|
|
@@ -1971,15 +1982,6 @@ def cmd_grounding_audit(argv: list[str]) -> int:
|
|
|
1971
1982
|
l3mix[k] = l3mix.get(k, 0) + n
|
|
1972
1983
|
print(f" source-verified (Level 3): {l3_checked} claim(s) read against the "
|
|
1973
1984
|
"original document - " + ", ".join(f"{k} x{n}" for k, n in sorted(l3mix.items())))
|
|
1974
|
-
if total_cits:
|
|
1975
|
-
# Outside the branch above on purpose: it only runs with something checkable, and a
|
|
1976
|
-
# run where nothing was checkable is the one that most needs this said.
|
|
1977
|
-
from compass.grounding_rollup import coverage_line, exclusion_lines, rollup as _rollup
|
|
1978
|
-
roll = _rollup(results)
|
|
1979
|
-
print(f" coverage of {total_cits} citation(s): "
|
|
1980
|
-
f"{coverage_line(roll['verification'])}.")
|
|
1981
|
-
for line in exclusion_lines(roll["exclusions"]):
|
|
1982
|
-
print(f" {line}.")
|
|
1983
1985
|
if total_cits == 0:
|
|
1984
1986
|
# 0 citations is either a retrieval-only export (nothing to audit) or, far more often,
|
|
1985
1987
|
# the answer field is not mapped - say which, loudly, instead of a silent INFO.
|
|
@@ -2648,8 +2650,9 @@ def cmd_readiness(argv: list[str]) -> int:
|
|
|
2648
2650
|
"every finding. No live connections, no LLM. A stage with no artifact is "
|
|
2649
2651
|
"'not examined' and caps the verdict at AT RISK. Exit 0 READY, 1 otherwise, "
|
|
2650
2652
|
"2 bad input.")
|
|
2651
|
-
p.add_argument("--discover",
|
|
2652
|
-
help="`compass discover --output-format json` report"
|
|
2653
|
+
p.add_argument("--discover", metavar="FILE",
|
|
2654
|
+
help="`compass discover --output-format json` report. With --project, found "
|
|
2655
|
+
"at reports/<project>-discovery-report.json when not given")
|
|
2653
2656
|
p.add_argument("--grounding", metavar="FILE", help="`grounding-audit --format json` report")
|
|
2654
2657
|
p.add_argument("--benchmark", metavar="FILE", help="`benchmark --json` (or `simulate --json`)")
|
|
2655
2658
|
p.add_argument("--drift", metavar="FILE", help="`compass drift --json` output")
|
|
@@ -2664,9 +2667,9 @@ def cmd_readiness(argv: list[str]) -> int:
|
|
|
2664
2667
|
|
|
2665
2668
|
from compass.config import load_settings, project_config_file
|
|
2666
2669
|
from compass.readiness import (Policy, ReadinessInputError, assess, format_readiness,
|
|
2667
|
-
load_artifact, render_html)
|
|
2670
|
+
load_artifact, locate_artifacts, render_html)
|
|
2668
2671
|
|
|
2669
|
-
|
|
2672
|
+
given = {"ingestion": args.discover, "retrieval": args.benchmark,
|
|
2670
2673
|
"grounding": args.grounding, "drift": args.drift, "fidelity": args.fidelity}
|
|
2671
2674
|
if args.project and project_config_file(args.project) is None:
|
|
2672
2675
|
print(f" Project '{args.project}' not found (config/projects/{args.project}.yaml).",
|
|
@@ -2676,9 +2679,19 @@ def cmd_readiness(argv: list[str]) -> int:
|
|
|
2676
2679
|
settings = (load_settings(project=args.project, env=args.env or None)
|
|
2677
2680
|
if args.project else None)
|
|
2678
2681
|
policy = Policy.from_config(settings.readiness if settings else None)
|
|
2682
|
+
paths, hints = locate_artifacts(
|
|
2683
|
+
given, args.project, getattr(getattr(settings, "readiness", None), "artifacts", None))
|
|
2684
|
+
for stage, path in sorted(paths.items()):
|
|
2685
|
+
if not given.get(stage):
|
|
2686
|
+
print(f" {stage}: using {path}", file=sys.stderr)
|
|
2687
|
+
if "ingestion" not in paths:
|
|
2688
|
+
print(" readiness needs a discover report: pass --discover FILE"
|
|
2689
|
+
+ (f", or {hints['ingestion']}" if "ingestion" in hints else
|
|
2690
|
+
", or --project to look for one"), file=sys.stderr)
|
|
2691
|
+
return 2
|
|
2679
2692
|
artifacts = {stage: load_artifact(path) for stage, path in paths.items() if path}
|
|
2680
|
-
report = assess(artifacts, labels=
|
|
2681
|
-
|
|
2693
|
+
report = assess(artifacts, labels=dict(paths), policy=policy, project=args.project,
|
|
2694
|
+
hints=hints)
|
|
2682
2695
|
except ReadinessInputError as exc:
|
|
2683
2696
|
print(f" {exc}", file=sys.stderr)
|
|
2684
2697
|
return 2
|
|
@@ -830,7 +830,8 @@ class EvalConfig:
|
|
|
830
830
|
# `compass fidelity` matching, all optional: normalization (minimal | standard | aggressive),
|
|
831
831
|
# match (shingle | exact), shingle_k, coverage_min ({default: 0.9, <document type>: 0.97}),
|
|
832
832
|
# type_field, prefer_snapshot, chunk_integrity, page_tolerance, page_field, page_end_field,
|
|
833
|
-
# position_field
|
|
833
|
+
# position_field, text_field (the index field holding chunk text; default gt_index_text_field,
|
|
834
|
+
# then gt_chunk_text_field). Falls back to the fidelity_* keys below.
|
|
834
835
|
fidelity: dict = field(default_factory=dict)
|
|
835
836
|
# Extractor snapshots, for attributing loss: provider, location, format, formats. See
|
|
836
837
|
# compass/providers/snapshot.py. Empty = findings stay UNATTRIBUTED.
|
|
@@ -871,6 +872,9 @@ class ReadinessConfig:
|
|
|
871
872
|
|
|
872
873
|
severity: dict[str, str] = field(default_factory=dict)
|
|
873
874
|
waived_stages: list[str] = field(default_factory=list)
|
|
875
|
+
# Where each stage's JSON artifact lives, {stage: path}; "{project}" is filled in. A stage
|
|
876
|
+
# not listed is looked for at reports/<project>-<stage>.json (see compass/readiness.py).
|
|
877
|
+
artifacts: dict[str, str] = field(default_factory=dict)
|
|
874
878
|
min_recall: float = 0.0
|
|
875
879
|
min_kb_confirmed_pct: float = 0.0
|
|
876
880
|
|
|
@@ -960,6 +964,10 @@ class ConsistencyConfig:
|
|
|
960
964
|
# Chunk field naming the source object: two versions of one source share this and differ on
|
|
961
965
|
# vector_etag_field. Used to detect old versions left searchable after a re-ingest.
|
|
962
966
|
vector_source_field: str = "s3_key"
|
|
967
|
+
# Every field that names one document across its versions. Empty = vector_source_field. A
|
|
968
|
+
# pipeline that writes each version under a new object key still keeps the file name, so
|
|
969
|
+
# [s3_key, file_name] catches both; only list a field that is unique per document.
|
|
970
|
+
version_group_fields: list[str] = field(default_factory=list)
|
|
963
971
|
# The graph predicate carrying the same hash (short name, as the query returns it).
|
|
964
972
|
graph_etag_predicate: str = "eTag"
|
|
965
973
|
# Fields that should agree between vector chunk metadata and graph predicates,
|
|
@@ -1025,7 +1033,7 @@ class Settings:
|
|
|
1025
1033
|
# --------------------------------------------------------------------------- #
|
|
1026
1034
|
# Non-service top-level keys that are legitimately not a service block.
|
|
1027
1035
|
_META_KEYS = frozenset({"default_env", "display_name", "environments", "skip_steps",
|
|
1028
|
-
"pipeline_dependencies", "suppressions"})
|
|
1036
|
+
"pipeline_dependencies", "suppressions", "strict_config"})
|
|
1029
1037
|
# The service-config blocks that may appear at the top level or under an environment.
|
|
1030
1038
|
# Single source of truth: the flatten loop AND the unknown-key check both read this, so a
|
|
1031
1039
|
# new block can never be added to one and forgotten in the other (which is exactly how
|
|
@@ -1072,7 +1080,7 @@ def _hydrate(cls: type, data: dict | None) -> Any:
|
|
|
1072
1080
|
_MAPPING_KEYS: dict[tuple[str, str], tuple[str, ...]] = {
|
|
1073
1081
|
("eval", "fidelity"): ("normalization", "match", "shingle_k", "coverage_min", "type_field",
|
|
1074
1082
|
"prefer_snapshot", "chunk_integrity", "page_tolerance", "page_field",
|
|
1075
|
-
"page_end_field", "position_field"),
|
|
1083
|
+
"page_end_field", "position_field", "text_field"),
|
|
1076
1084
|
("eval", "snapshot"): ("provider", "location", "format", "formats"),
|
|
1077
1085
|
("eval", "source_exclusions"): ("repeated_on_pages", "min_chars", "roles", "patterns",
|
|
1078
1086
|
"page_roles", "must_retain"),
|
|
@@ -1274,9 +1282,21 @@ def load_settings(
|
|
|
1274
1282
|
for warning in unknown_keys(flat, settings):
|
|
1275
1283
|
log.warning(warning)
|
|
1276
1284
|
settings.config_warnings.append(warning)
|
|
1285
|
+
if settings.config_warnings and _strict(merged):
|
|
1286
|
+
# Off by default: a key added by a newer release must not stop an older one. A CI job
|
|
1287
|
+
# that wants a typo to fail the run turns it on.
|
|
1288
|
+
raise ValueError("strict_config: " + " ".join(settings.config_warnings))
|
|
1277
1289
|
return settings
|
|
1278
1290
|
|
|
1279
1291
|
|
|
1292
|
+
def _strict(merged: dict) -> bool:
|
|
1293
|
+
"""``strict_config: true`` in the project, or COMPASS_STRICT_CONFIG=1 in the environment."""
|
|
1294
|
+
flag = os.environ.get("COMPASS_STRICT_CONFIG", "")
|
|
1295
|
+
if flag:
|
|
1296
|
+
return flag.strip().lower() in ("1", "true", "yes", "on")
|
|
1297
|
+
return bool(merged.get("strict_config", False))
|
|
1298
|
+
|
|
1299
|
+
|
|
1280
1300
|
def _apply_literal_port(block: Any) -> None:
|
|
1281
1301
|
"""Honour a literal ``redis.port``, as an environments block naturally writes it.
|
|
1282
1302
|
|
|
@@ -215,6 +215,20 @@ def _lint_fidelity(settings: Any) -> list[Finding]:
|
|
|
215
215
|
name = str(snapshot.get("format") or "canonical")
|
|
216
216
|
if name != "canonical" and name not in (snapshot.get("formats") or {}):
|
|
217
217
|
out.append(("warn", f"eval.snapshot.format '{name}' has no entry in eval.snapshot.formats."))
|
|
218
|
+
from compass.providers.snapshot import LOCATION_FIELDS, location_fields
|
|
219
|
+
|
|
220
|
+
location = str(snapshot.get("location") or "")
|
|
221
|
+
if not location:
|
|
222
|
+
out.append(("warn", "eval.snapshot.location is empty, so no snapshot can be found."))
|
|
223
|
+
else:
|
|
224
|
+
try:
|
|
225
|
+
unknown = sorted(set(location_fields(location)) - set(LOCATION_FIELDS))
|
|
226
|
+
except ValueError as exc:
|
|
227
|
+
unknown = [f"unparseable: {exc}"]
|
|
228
|
+
if unknown:
|
|
229
|
+
out.append(("error", f"eval.snapshot.location uses "
|
|
230
|
+
f"{', '.join('{' + u + '}' for u in unknown)}, which nothing fills in; the "
|
|
231
|
+
f"placeholders are {', '.join('{' + f + '}' for f in LOCATION_FIELDS)}."))
|
|
218
232
|
extractor = str(getattr(ev, "source_extractor", "auto") or "auto").lower()
|
|
219
233
|
if extractor != "auto" and extractor not in available("extractor"):
|
|
220
234
|
out.append(("warn", f"eval.source_extractor '{extractor}' is not registered "
|
|
@@ -54,6 +54,9 @@ CONTENT_LOSS = "CONTENT_LOSS"
|
|
|
54
54
|
NUMBERS_MISSING = "NUMBERS_MISSING"
|
|
55
55
|
VALUE_DRIFT = "VALUE_DRIFT"
|
|
56
56
|
UNVERIFIABLE = "UNVERIFIABLE"
|
|
57
|
+
#: The stored text and the source share nothing. Either the setup reads the wrong field or file,
|
|
58
|
+
#: or the store holds another document under this id. Both are faults, and neither is a loss.
|
|
59
|
+
SOURCE_MISMATCH = "SOURCE_MISMATCH"
|
|
57
60
|
|
|
58
61
|
#: 8 means 16 normalised characters. Shorter units recur across a business document ("across
|
|
59
62
|
#: the group"), so a deleted line still reads as mostly present: measured on a 523-page report,
|
|
@@ -65,6 +68,7 @@ _SHORT_LINE_WORDS = 4 # at or under this a line is treated as a fragm
|
|
|
65
68
|
_MIN_COMPARE_CHARS = 12 # normalised text shorter than this says nothing either way
|
|
66
69
|
_LINE_PRESENT = 0.6 # share of a line's units in the store for it to count as there
|
|
67
70
|
_TRACEABLE = 0.3 # below this a chunk does not appear to come from the source
|
|
71
|
+
_NOTHING_MATCHES = 0.05 # coverage below which, with no chunk traceable, the sides differ
|
|
68
72
|
_TABLE_LINE_DIGITS = 0.4 # share of numeric tokens at which a line is treated as a table row
|
|
69
73
|
_GARBLED_SHORT_TOKENS = 0.5 # share of 1-2 letter tokens at which a text layer is broken
|
|
70
74
|
_PIECE_CHARS = 120 # normalised characters judged as one unit
|
|
@@ -109,6 +113,7 @@ class DocumentFidelity:
|
|
|
109
113
|
excluded: dict = field(default_factory=dict)
|
|
110
114
|
attributions: dict = field(default_factory=dict)
|
|
111
115
|
chunk_integrity: dict = field(default_factory=dict)
|
|
116
|
+
mismatched: bool = False # store and source are different texts: a setup fault
|
|
112
117
|
|
|
113
118
|
|
|
114
119
|
@dataclass
|
|
@@ -352,6 +357,25 @@ def _merge_runs(missing: list[dict], limit: int) -> list[dict]:
|
|
|
352
357
|
return sorted(runs, key=lambda r: (-r["size"], r["page"]))[:limit]
|
|
353
358
|
|
|
354
359
|
|
|
360
|
+
def index_text_field(cfg: Any) -> str:
|
|
361
|
+
"""The index field holding chunk text: ``eval.fidelity.text_field``, else the shared keys.
|
|
362
|
+
|
|
363
|
+
``gt_chunk_text_field`` names the field in the eval file, which need not be the index's name
|
|
364
|
+
for the same text, so it is the last resort, not the first.
|
|
365
|
+
"""
|
|
366
|
+
raw = getattr(cfg, "fidelity", None) or {}
|
|
367
|
+
return (str(raw.get("text_field") or "") or getattr(cfg, "gt_index_text_field", "")
|
|
368
|
+
or getattr(cfg, "gt_chunk_text_field", "") or "text")
|
|
369
|
+
|
|
370
|
+
|
|
371
|
+
def _text_fields_hint(chunks: list[dict]) -> str:
|
|
372
|
+
"""Name the fields that do hold long text, so the fix is one config line, not a search."""
|
|
373
|
+
names = sorted({str(k) for c in chunks for k, v in c.items()
|
|
374
|
+
if isinstance(v, str) and len(v.strip()) >= 40})
|
|
375
|
+
hint = f" (fields holding text: {', '.join(names[:6])})" if names else ""
|
|
376
|
+
return hint + "; set eval.fidelity.text_field to the index field that holds the chunk text"
|
|
377
|
+
|
|
378
|
+
|
|
355
379
|
def compare_document(document: str, source_key: str, pages: list[str], chunks: list[dict],
|
|
356
380
|
cfg: Any, *, text_field: str = "text", version_field: str = "e_tag",
|
|
357
381
|
type_field: str = "document_type", snapshot: Any = None,
|
|
@@ -377,6 +401,11 @@ def compare_document(document: str, source_key: str, pages: list[str], chunks: l
|
|
|
377
401
|
result.coverage_required = required
|
|
378
402
|
|
|
379
403
|
stored = [str(c.get(text_field) or "") for c in chunks]
|
|
404
|
+
if not any(text.strip() for text in stored):
|
|
405
|
+
# Reading the wrong field leaves the store empty, and an empty store scores 0% on every
|
|
406
|
+
# healthy document. That is a setup fault, so it is reported as one, never as a loss.
|
|
407
|
+
result.reason = f"no chunk has text in field '{text_field}'" + _text_fields_hint(chunks)
|
|
408
|
+
return result
|
|
380
409
|
store = _Text(stored, opts)
|
|
381
410
|
# Digits removed: telling a rewritten value from a dropped row means asking whether the
|
|
382
411
|
# row's words survived, and the changed digits sit in the middle of them.
|
|
@@ -487,10 +516,13 @@ def compare_document(document: str, source_key: str, pages: list[str], chunks: l
|
|
|
487
516
|
"attribution": EXTRACTOR_MISS, "_at": position})
|
|
488
517
|
|
|
489
518
|
origin = _Text(pages or [" ".join(p) for p in baseline], opts)
|
|
519
|
+
assessable = 0
|
|
490
520
|
for text in stored:
|
|
491
521
|
units = grams(normalize(text, opts.normalization), opts.k, opts.normalization)
|
|
492
|
-
if len(units) >= 8
|
|
493
|
-
|
|
522
|
+
if len(units) >= 8:
|
|
523
|
+
assessable += 1
|
|
524
|
+
if len(units & origin.units) / len(units) < _TRACEABLE:
|
|
525
|
+
result.untraceable_chunks += 1
|
|
494
526
|
result.missing_passages = _merge_runs(missing, max_examples)
|
|
495
527
|
result.missing_numbers = missing_numbers[:max_examples * 3]
|
|
496
528
|
result.attributions = dict(Counter(m["attribution"] for m in missing + missing_numbers))
|
|
@@ -507,6 +539,19 @@ def compare_document(document: str, source_key: str, pages: list[str], chunks: l
|
|
|
507
539
|
if result.pages_compared == 0 or (result.text_coverage is None and not result.numbers_checked):
|
|
508
540
|
result.reason = "no comparable text (image-only, garbled text layer, or entirely excluded)"
|
|
509
541
|
return result
|
|
542
|
+
if (assessable and result.untraceable_chunks == assessable
|
|
543
|
+
and (result.text_coverage or 0) < _NOTHING_MATCHES):
|
|
544
|
+
# Not one stored chunk comes from this source, and almost none of the source is stored:
|
|
545
|
+
# the two sides are different texts. A wrong text field or a source key naming another
|
|
546
|
+
# file does this, and reporting it as total loss sends the reader after the wrong fault.
|
|
547
|
+
result.mismatched = True
|
|
548
|
+
result.verdict = SOURCE_MISMATCH
|
|
549
|
+
result.text_coverage = None
|
|
550
|
+
result.chunk_integrity = {}
|
|
551
|
+
result.reason = (f"none of the {assessable} stored chunk(s) trace to this source: either "
|
|
552
|
+
f"'{text_field}' is not the chunk text or '{source_key}' is another "
|
|
553
|
+
"document's file, or the store holds another document under this id")
|
|
554
|
+
return result
|
|
510
555
|
if result.retained_missing:
|
|
511
556
|
result.verdict = CONTENT_LOSS
|
|
512
557
|
result.reason = f"{len(result.retained_missing)} must-retain passage(s) are not in the store"
|
|
@@ -566,7 +611,7 @@ def fidelity_report(settings: Any, *, sample: int = 25, documents: Optional[list
|
|
|
566
611
|
cfg = settings.eval
|
|
567
612
|
rc = settings.redis
|
|
568
613
|
key_fields = list(getattr(cfg, "citation_source_key_fields", []) or [])
|
|
569
|
-
text_field =
|
|
614
|
+
text_field = index_text_field(cfg)
|
|
570
615
|
version_field = getattr(getattr(settings, "consistency", None), "vector_etag_field", "") or "e_tag"
|
|
571
616
|
type_field = str((getattr(cfg, "fidelity", None) or {}).get("type_field") or "document_type")
|
|
572
617
|
opts = _options(cfg)
|
|
@@ -582,6 +627,8 @@ def fidelity_report(settings: Any, *, sample: int = 25, documents: Optional[list
|
|
|
582
627
|
results: list[DocumentFidelity] = []
|
|
583
628
|
snapshots_used = 0
|
|
584
629
|
snapshot_errors: Counter = Counter()
|
|
630
|
+
snapshots_missing: list[str] = []
|
|
631
|
+
provider = getattr(fetch_snapshot, "__self__", None)
|
|
585
632
|
for doc in ids:
|
|
586
633
|
try:
|
|
587
634
|
chunks = vectorstore.fetch_chunks(doc, limit=rc.max_chunks_per_document) or []
|
|
@@ -591,6 +638,8 @@ def fidelity_report(settings: Any, *, sample: int = 25, documents: Optional[list
|
|
|
591
638
|
etag = next((str(c[version_field]) for c in chunks if c.get(version_field)), "")
|
|
592
639
|
try:
|
|
593
640
|
snapshot = fetch_snapshot(doc, etag, key)
|
|
641
|
+
if snapshot is None:
|
|
642
|
+
snapshots_missing.append(str(getattr(provider, "last_key", "") or ""))
|
|
594
643
|
except Exception as exc: # noqa: BLE001 - falls back to source vs store
|
|
595
644
|
snapshot_errors[str(exc)[:120]] += 1
|
|
596
645
|
pages = list(fetch_pages(key) or []) if key and fetch_pages else []
|
|
@@ -616,19 +665,39 @@ def fidelity_report(settings: Any, *, sample: int = 25, documents: Optional[list
|
|
|
616
665
|
rates = [r.text_coverage for r in compared if r.text_coverage is not None]
|
|
617
666
|
integrity = _integrity_totals(results)
|
|
618
667
|
problems += [f"snapshot unreadable for {n} document(s): {msg}" for msg, n in snapshot_errors.items()]
|
|
668
|
+
if snapshots_missing:
|
|
669
|
+
where = next((k for k in snapshots_missing if k), "")
|
|
670
|
+
problems.append(f"no snapshot found for {len(snapshots_missing)} document(s)"
|
|
671
|
+
+ (f", for example at '{where}'" if where else "")
|
|
672
|
+
+ ": check that the stored e_tag is the one the extractor output is "
|
|
673
|
+
"written under, and eval.snapshot.location")
|
|
674
|
+
mismatched = [r.document for r in results if r.mismatched]
|
|
675
|
+
if mismatched:
|
|
676
|
+
problems.append(f"{len(mismatched)} document(s) share no text with their source. Check "
|
|
677
|
+
f"eval.fidelity.text_field (now '{text_field}') and "
|
|
678
|
+
"eval.citation_source_key_fields first; if both are right, the store "
|
|
679
|
+
"holds the wrong text for those documents")
|
|
680
|
+
textless = [r.document for r in results if r.reason.startswith("no chunk has text")]
|
|
681
|
+
if textless:
|
|
682
|
+
problems.append(f"{len(textless)} document(s) have no chunk text in '{text_field}': "
|
|
683
|
+
"set eval.fidelity.text_field")
|
|
619
684
|
return {
|
|
620
685
|
"verdict": ("NOT EXAMINED" if not compared else
|
|
621
686
|
"CONTENT OK" if counts[CONTENT_OK] == len(compared) else "FINDINGS"),
|
|
622
687
|
"documents": len(results), "compared": len(compared),
|
|
623
688
|
"unverifiable": counts[UNVERIFIABLE],
|
|
689
|
+
"mismatched": len(mismatched),
|
|
690
|
+
"text_field": text_field,
|
|
624
691
|
"content_ok": counts[CONTENT_OK],
|
|
625
692
|
"content_loss": counts[CONTENT_LOSS],
|
|
626
693
|
"numbers_missing": counts[NUMBERS_MISSING],
|
|
627
694
|
"value_drift": counts[VALUE_DRIFT],
|
|
695
|
+
"source_mismatch": counts[SOURCE_MISMATCH],
|
|
628
696
|
"mean_text_coverage": round(sum(rates) / len(rates), 4) if rates else None,
|
|
629
697
|
"chunk_integrity": integrity,
|
|
630
698
|
"excluded": dict(excluded), "rule_errors": problems,
|
|
631
699
|
"attributions": dict(attributions), "snapshots_used": snapshots_used,
|
|
700
|
+
"snapshots_missing": len(snapshots_missing),
|
|
632
701
|
"attribution_note": (f"Attributed from {snapshots_used} extractor snapshot(s)."
|
|
633
702
|
if snapshots_used else
|
|
634
703
|
"Findings are UNATTRIBUTED: separating extractor loss from pipeline "
|
|
@@ -663,7 +732,8 @@ def format_report(report: dict, limit: int = 15) -> str:
|
|
|
663
732
|
f" Documents: {report['documents']} compared: {report['compared']} "
|
|
664
733
|
f"not comparable: {report['unverifiable']}",
|
|
665
734
|
f" OK: {report['content_ok']} content loss: {report['content_loss']} "
|
|
666
|
-
f"numbers missing: {report['numbers_missing']} value drift: {report.get('value_drift', 0)}"
|
|
735
|
+
f"numbers missing: {report['numbers_missing']} value drift: {report.get('value_drift', 0)}"
|
|
736
|
+
+ (f" source mismatch: {report['source_mismatch']}" if report.get("source_mismatch") else ""),
|
|
667
737
|
f" Mean text coverage: {_pct(report['mean_text_coverage'])} (of text that could be compared)"]
|
|
668
738
|
integrity = report.get("chunk_integrity") or {}
|
|
669
739
|
if integrity.get("checked"):
|
|
@@ -676,7 +746,7 @@ def format_report(report: dict, limit: int = 15) -> str:
|
|
|
676
746
|
L.append(f" Excluded by '{rule}': {n}")
|
|
677
747
|
for err in report["rule_errors"]:
|
|
678
748
|
L.append(f" WARNING: {err}")
|
|
679
|
-
order = {
|
|
749
|
+
order = {SOURCE_MISMATCH: 0, CONTENT_LOSS: 1, VALUE_DRIFT: 2, NUMBERS_MISSING: 3, UNVERIFIABLE: 4}
|
|
680
750
|
flagged = sorted((r for r in report["results"] if r["verdict"] != CONTENT_OK),
|
|
681
751
|
key=lambda r: (order.get(r["verdict"], 4), r["text_coverage"] or 0))
|
|
682
752
|
if flagged:
|
|
@@ -702,7 +772,9 @@ def format_report(report: dict, limit: int = 15) -> str:
|
|
|
702
772
|
L.append(f" {row['status']} #{row['position']}: {row['detail'][:80]}")
|
|
703
773
|
if len(flagged) > limit:
|
|
704
774
|
L.append(f" ... and {len(flagged) - limit} more (see --json)")
|
|
705
|
-
L += ["", " " + report["attribution_note"],
|
|
775
|
+
L += ["", " " + report["attribution_note"],
|
|
776
|
+
f" Method: {report['method_version']}, chunk text from '{report.get('text_field', 'text')}'",
|
|
777
|
+
"=" * 72]
|
|
706
778
|
return "\n".join(L)
|
|
707
779
|
|
|
708
780
|
|