compass-kb-validation 4.0.2__tar.gz → 4.2.0__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.
Files changed (198) hide show
  1. {compass_kb_validation-4.0.2/compass_kb_validation.egg-info → compass_kb_validation-4.2.0}/PKG-INFO +85 -10
  2. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/README.md +84 -9
  3. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/__init__.py +1 -1
  4. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/alias.py +4 -1
  5. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/ask.py +9 -1
  6. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/benchmark.py +64 -5
  7. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/check_catalog.py +20 -3
  8. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/chunk_coherence.py +65 -0
  9. compass_kb_validation-4.2.0/compass/chunk_ref.py +61 -0
  10. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/cli.py +277 -35
  11. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/config/__init__.py +146 -7
  12. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/config_lint.py +17 -4
  13. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/content_fidelity.py +545 -87
  14. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/content_inspect.py +89 -14
  15. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/corpus.py +102 -4
  16. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/corpus_health.py +6 -2
  17. compass_kb_validation-4.2.0/compass/cross_index.py +361 -0
  18. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/eval_enrich.py +7 -7
  19. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/eval_interop.py +67 -18
  20. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/evidence.py +12 -6
  21. compass_kb_validation-4.2.0/compass/findings.py +486 -0
  22. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/grounding.py +9 -4
  23. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/lineage.py +20 -4
  24. compass_kb_validation-4.2.0/compass/manifest.py +155 -0
  25. compass_kb_validation-4.2.0/compass/metadata_checks.py +416 -0
  26. compass_kb_validation-4.2.0/compass/pdf_support.py +61 -0
  27. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/pipeline/__init__.py +1 -1
  28. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/provenance.py +22 -10
  29. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/__init__.py +17 -1
  30. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/embedding.py +30 -0
  31. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/extractor.py +50 -4
  32. compass_kb_validation-4.2.0/compass/providers/snapshot.py +314 -0
  33. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/source.py +2 -0
  34. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/storage.py +158 -5
  35. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/vectorstore.py +169 -6
  36. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/readiness.py +109 -14
  37. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/__init__.py +735 -264
  38. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/export.py +4 -1
  39. compass_kb_validation-4.2.0/compass/report/fidelity_view.py +417 -0
  40. compass_kb_validation-4.2.0/compass/snapshot_doctor.py +212 -0
  41. compass_kb_validation-4.2.0/compass/structure_checks.py +816 -0
  42. compass_kb_validation-4.2.0/compass/text_probes.py +129 -0
  43. compass_kb_validation-4.2.0/compass/triage.py +295 -0
  44. compass_kb_validation-4.2.0/compass/validators/metadata_checks.py +132 -0
  45. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/redis_chunks.py +48 -14
  46. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/registry.py +12 -1
  47. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/retrieval_quality.py +57 -19
  48. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/s3_storage.py +26 -10
  49. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0/compass_kb_validation.egg-info}/PKG-INFO +85 -10
  50. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass_kb_validation.egg-info/SOURCES.txt +19 -0
  51. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/discover_and_validate.py +183 -8
  52. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_check_catalog.py +3 -1
  53. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_drift.py +7 -0
  54. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_fidelity_precision.py +4 -1
  55. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_grounding_rollup.py +3 -1
  56. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_measurement_fixes.py +9 -4
  57. compass_kb_validation-4.2.0/tests/test_metadata_checks.py +263 -0
  58. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_redis_chunks.py +11 -3
  59. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_report_store_section.py +1 -1
  60. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_reporting.py +12 -5
  61. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_storage_validator.py +6 -2
  62. compass_kb_validation-4.2.0/tests/test_structure_checks.py +386 -0
  63. compass_kb_validation-4.2.0/tests/test_tooling_420.py +548 -0
  64. compass_kb_validation-4.2.0/tests/test_v410_any_pipeline.py +230 -0
  65. compass_kb_validation-4.2.0/tests/test_v410_gate.py +444 -0
  66. compass_kb_validation-4.2.0/tests/test_v410_portability.py +181 -0
  67. compass_kb_validation-4.2.0/tests/test_v420_gate.py +355 -0
  68. compass_kb_validation-4.2.0/tests/test_v420_report_truth.py +458 -0
  69. compass_kb_validation-4.0.2/compass/providers/snapshot.py +0 -161
  70. compass_kb_validation-4.0.2/compass/text_probes.py +0 -57
  71. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/LICENSE +0 -0
  72. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/__main__.py +0 -0
  73. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/baseline.py +0 -0
  74. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/chunk_eval.py +0 -0
  75. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/chunk_integrity.py +0 -0
  76. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/citation.py +0 -0
  77. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/diagnostics.py +0 -0
  78. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/diff.py +0 -0
  79. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/drift.py +0 -0
  80. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/embedding_drift.py +0 -0
  81. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/grounding_diff.py +0 -0
  82. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/grounding_rollup.py +0 -0
  83. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/gt_lint.py +0 -0
  84. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/health.py +0 -0
  85. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/incremental.py +0 -0
  86. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/init_wizard.py +0 -0
  87. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/live_dashboard.py +0 -0
  88. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/mcp_server.py +0 -0
  89. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/models/__init__.py +0 -0
  90. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/notifications.py +0 -0
  91. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/profiler.py +0 -0
  92. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/providers/graph.py +0 -0
  93. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/quality_gate.py +0 -0
  94. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/remediation.py +0 -0
  95. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/_report_css.py +0 -0
  96. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/_report_js.py +0 -0
  97. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/analysis.py +0 -0
  98. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/audit.py +0 -0
  99. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/grounding_report.py +0 -0
  100. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/report/shell.py +0 -0
  101. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/retrieval_analysis.py +0 -0
  102. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/simulate.py +0 -0
  103. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/text_match.py +0 -0
  104. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/trend_tracker.py +0 -0
  105. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/utils/__init__.py +0 -0
  106. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/__init__.py +0 -0
  107. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/api_upload.py +0 -0
  108. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/base.py +0 -0
  109. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/base_sparql.py +0 -0
  110. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/cross_stage.py +0 -0
  111. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/graphdb_metadata.py +0 -0
  112. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass/validators/neptune_metadata.py +0 -0
  113. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass_kb_validation.egg-info/dependency_links.txt +0 -0
  114. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass_kb_validation.egg-info/entry_points.txt +0 -0
  115. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass_kb_validation.egg-info/requires.txt +0 -0
  116. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/compass_kb_validation.egg-info/top_level.txt +0 -0
  117. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/ingestion_validation/__init__.py +0 -0
  118. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/profile_kb.py +0 -0
  119. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/pyproject.toml +0 -0
  120. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/run_validation.py +0 -0
  121. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/setup.cfg +0 -0
  122. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_alias.py +0 -0
  123. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_alias_disambiguation.py +0 -0
  124. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_alias_temporal.py +0 -0
  125. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_alt_adapters.py +0 -0
  126. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_analysis_report.py +0 -0
  127. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_api_upload.py +0 -0
  128. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_ask.py +0 -0
  129. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_baseline.py +0 -0
  130. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_benchmark.py +0 -0
  131. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_calibrate_truth.py +0 -0
  132. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_chunk_eval.py +0 -0
  133. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_chunk_integrity.py +0 -0
  134. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_chunk_structure_checks.py +0 -0
  135. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_citation.py +0 -0
  136. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_citation_levels.py +0 -0
  137. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_cli.py +0 -0
  138. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_cli_commands.py +0 -0
  139. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_compat_shim.py +0 -0
  140. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_config.py +0 -0
  141. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_config_lint.py +0 -0
  142. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_content_fidelity.py +0 -0
  143. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_content_inspect.py +0 -0
  144. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_corpus.py +0 -0
  145. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_corpus_health.py +0 -0
  146. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_coverage.py +0 -0
  147. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_coverage_and_drift_config.py +0 -0
  148. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_cross_stage.py +0 -0
  149. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_diagnostics.py +0 -0
  150. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_diff.py +0 -0
  151. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_discover_cli.py +0 -0
  152. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_discovery_parallel.py +0 -0
  153. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_embedding_contract.py +0 -0
  154. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_embedding_drift.py +0 -0
  155. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_eval_enrich.py +0 -0
  156. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_eval_interop.py +0 -0
  157. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_evidence.py +0 -0
  158. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_gate.py +0 -0
  159. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_graph_transport.py +0 -0
  160. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_graph_validators.py +0 -0
  161. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_grounding.py +0 -0
  162. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_grounding_report.py +0 -0
  163. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_health.py +0 -0
  164. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_incremental.py +0 -0
  165. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_init_wizard.py +0 -0
  166. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_lineage.py +0 -0
  167. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_manifest.py +0 -0
  168. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_mcp.py +0 -0
  169. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_migration.py +0 -0
  170. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_models.py +0 -0
  171. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_multi_index.py +0 -0
  172. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_neptune_bugfixes.py +0 -0
  173. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_neptune_bugfixes2.py +0 -0
  174. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_notifications.py +0 -0
  175. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_pipeline.py +0 -0
  176. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_profiler.py +0 -0
  177. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_providers.py +0 -0
  178. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_quality_gate.py +0 -0
  179. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_readiness.py +0 -0
  180. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_registry.py +0 -0
  181. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_remediation.py +0 -0
  182. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_requirements_config.py +0 -0
  183. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_retrieval_assertions.py +0 -0
  184. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_retrieval_fields.py +0 -0
  185. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_retrieval_quality.py +0 -0
  186. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_review_hardening.py +0 -0
  187. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_run_cli.py +0 -0
  188. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_simulate.py +0 -0
  189. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_source_exclusions.py +0 -0
  190. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_source_verification.py +0 -0
  191. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_sources.py +0 -0
  192. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_trends.py +0 -0
  193. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_universal_concerns.py +0 -0
  194. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_utils.py +0 -0
  195. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_v402_fixes.py +0 -0
  196. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_v4_defect_fixes.py +0 -0
  197. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/tests/test_vector_fastpath.py +0 -0
  198. {compass_kb_validation-4.0.2 → compass_kb_validation-4.2.0}/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.2
3
+ Version: 4.2.0
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
@@ -205,7 +205,8 @@ a knowledge base — they don't turn COMPASS into a retrieval app or an agent-se
205
205
  answer); `compass mcp` is an **inspection surface** (read-only KB tools an agent can call, not
206
206
  a serving layer). Everything here stays on COMPASS's side of the line and never affects a
207
207
  validation pass/fail. They read an `embedding:` block in the project YAML (provider `openai` /
208
- `azure_openai` / `bedrock`, `model_id`, `dimensions`) so a query is embedded the way ingestion was.
208
+ `azure_openai` / `bedrock` / `openai_compatible` for a self-hosted server such as vLLM, Ollama or
209
+ TEI, `model_id`, `dimensions`) so a query is embedded the way ingestion was.
209
210
 
210
211
  ```bash
211
212
  # Ask the KB a question - returns the ranked chunks it would retrieve (no generated answer)
@@ -339,9 +340,15 @@ eval:
339
340
  match: shingle # shingle | exact
340
341
  coverage_min: {default: 0.90, quarterly: 0.97} # keyed by document_type
341
342
  prefer_snapshot: true
343
+ figure_regions: snapshot # snapshot | off: numbers inside figures reported apart
344
+ figure_types: [figure, chart, image] # snapshot element types that are figures
345
+ lost_passages_allowed: 0 # named lost passages tolerated (snapshot baseline)
346
+ figure_words: gate # gate | report: lost words inside figures gate or not
347
+ number_format: "1,234.5" # or "1.234,5" | "1 234,5" | "1'234.5"
342
348
  source_exclusions: # nothing is excluded that is not listed here
343
349
  repeated_on_pages: 5 # headers and footers
344
- min_chars: 75 # small fragments
350
+ min_chars: 75 # small fragments (every element type)
351
+ figure_min_chars: 75 # figure elements this short, dropped by design
345
352
  patterns: ["(?i)^past performance"] # by-design notices
346
353
  page_roles: {disclaimer: "(?i)^important disclosures"}
347
354
  roles: [marginalia, logo, attestation] # read from a snapshot, so they need one
@@ -360,6 +367,16 @@ A document where not one chunk traces to its source is `SOURCE_MISMATCH`: either
360
367
  source key is wrong, or the store holds another document's text under that id. Neither is averaged
361
368
  into coverage as a 0%. A snapshot that cannot be found is reported with the key it was looked for at.
362
369
 
370
+ What gates is what can be named. Against a snapshot, every passage the extractor produced and the
371
+ store lacks is a lost passage, reported with its element type, page and box, and one is enough for
372
+ `CONTENT_LOSS` (`lost_passages_allowed` raises that). A number in body text that is not stored is
373
+ listed with its page and sentence. Numbers inside a figure region, and runs of evenly spaced numbers
374
+ such as an axis (`20.0% 22.0% 24.0%`), are reported apart as `figure_numbers` and never gate; words
375
+ inside a figure are still compared. Page coverage is shown as context, not as a gate. The JSON keeps
376
+ every finding, body text first; the console shows the first few. A caption or a `Source:` note
377
+ stored more than one chunk away from its figure is `CAPTION_DETACHED`, with both chunk ids. A
378
+ source that cannot be read (encrypted, image-only) is compared through its snapshot.
379
+
363
380
  Findings say what is missing, not who lost it, until you declare the extractor's own output. Any
364
381
  extractor that writes JSON works: map its fields once, and each finding becomes `PIPELINE_DROP`,
365
382
  `PIPELINE_ALTER` or `EXTRACTOR_MISS`.
@@ -369,18 +386,68 @@ eval:
369
386
  snapshot:
370
387
  provider: storage_json
371
388
  location: "snapshots/{project}/{id}/{e_tag}/document.json" # also {source_key}
389
+ fallback_locations: ["backup/{e_tag}/document.json"] # tried in order after it
390
+ version: latest_with_elements # current (default) | latest_with_elements
372
391
  format: my_extractor
373
392
  formats:
374
- my_extractor: # dotted paths into the extractor's JSON
375
- elements: "sections"
376
- type: "kind"
393
+ my_extractor: # paths into the extractor's JSON
394
+ elements: "metadata.element_list"
395
+ type: "chunk_type"
377
396
  text: "text"
378
- page: "page"
379
- bbox: "box"
397
+ order: "chunk_index"
398
+ page: "grounding[0].page" # [n] picks one item
399
+ boxes: "grounding[*].box" # [*] takes all: an element may have several boxes
400
+ box_keys: [left, top, right, bottom] # for boxes written as objects
401
+ page_base: 0 # the extractor counts pages from 0
380
402
  cells: "table.cells"
381
- order: "reading_order"
382
403
  ```
383
404
 
405
+ `version: latest_with_elements` reads older object versions when a later write replaced the element
406
+ list with a text-only file, or the key was deleted under bucket versioning. Each document's snapshot
407
+ is `present`, `superseded` (read from an older version or a fallback), `missing`, `wrong_shape` or
408
+ `unreadable`; the counts are in `snapshot_health`, and `readiness.min_snapshot_coverage` (0 to 1)
409
+ fails readiness when too few were read. `compass doctor` reads the snapshots of a few documents,
410
+ says which location and version holds the element list, and prints a `formats` entry to paste when
411
+ the mapping is wrong.
412
+
413
+ A passage the extractor produced and the store lacks is a pipeline drop, and it fails `readiness`
414
+ by default (`fidelity_pipeline_drop`); text missing from the extractor too stays advisory. Table
415
+ elements are compared like any passage, image links (`![name](url)`) and URLs are ignored on every
416
+ side, and a `Source:` line inside a text element is judged as a caption.
417
+
418
+ Structure is checked against the snapshot too, under `eval.structure` (every check reports "not
419
+ checked" when its input is missing): a heading stored with its section, a table in one chunk,
420
+ reading order, every page with text covered by a chunk, the page a chunk states, every source image
421
+ represented by a figure element, and pages whose text layer has no Unicode map. The chunk box and
422
+ chunk type checks run when the index carries those fields (`chunk_box_field`, `chunk_type_field`).
423
+
424
+ Index settings that change what every check reads:
425
+
426
+ ```yaml
427
+ redis:
428
+ text_field: content # the field holding chunk text
429
+ page_base: 0 # the index counts pages from 0; every page is read 1-based
430
+ production_index: kb_merged # the index production queries; reports say when they read another
431
+ coverage: full # every sampled check reads every item (default: sampled)
432
+ triage_file: config/triage.yaml # decisions kept between runs (see below)
433
+ ```
434
+
435
+ **Triage.** `triage_file` lists decisions on findings: `{key, decision: defect | by_design | false,
436
+ reason, owner, expires}`. Every finding carries a stable id and a key (`check|index|document|chunk`,
437
+ globs allowed); `by_design` and `false` never gate, expired entries are ignored with a warning, and
438
+ `compass triage stats` reports each check's precision over the labelled entries. Findings are marked
439
+ new, still open or resolved against the previous run, and `--export-findings DIR` writes one file
440
+ per owner with index, chunk id, chunk index, page and a snippet.
441
+
442
+ **Several indexes.** `discover` lists other indexes in the same store holding the same sources, and
443
+ `compass drift --project P --index-a A --index-b B` reports, per source document, content present
444
+ in one index and missing from the other.
445
+
446
+ **Document metadata.** The opt-in `metadata_checks` step (name it in `pipeline.steps`) checks that
447
+ date fields agree with each other and with the file name, that each document type carries its
448
+ period fields, that a type sits in its folder, and that chunks were ingested after the source last
449
+ changed. Every field, pattern and map is set under `metadata_checks:`.
450
+
384
451
  ### KB readiness
385
452
 
386
453
  `compass readiness --discover D.json [--grounding G.json] [--benchmark B.json] [--drift X.json]
@@ -410,6 +477,7 @@ it changes no verdict.
410
477
  | `corpus_at_risk` | risk | ingestion |
411
478
  | `corpus_verdict_missing` * | risk | ingestion |
412
479
  | `documents_unexamined` * (skipped, pending or empty checks) | risk | ingestion |
480
+ | `checks_not_run` * (a backend such as the PDF reader failed to load) | risk | ingestion |
413
481
  | `partial_run` * (`discover --since`) | risk | ingestion |
414
482
  | `retrieval_query_errors` * | risk | retrieval config |
415
483
  | `retrieval_found_nothing` | risk | retrieval config |
@@ -422,6 +490,12 @@ it changes no verdict.
422
490
  | `fidelity_numbers_missing` | advisory | ingestion |
423
491
  | `fidelity_value_drift` | advisory | ingestion |
424
492
  | `fidelity_source_mismatch` | risk | ingestion |
493
+ | `fidelity_caption_detached` | risk | ingestion |
494
+ | `fidelity_extractor_gap` (source text the extractor did not produce) | advisory | ingestion |
495
+ | `fidelity_pipeline_drop` (passages the extractor produced, missing from the store) | gate | ingestion |
496
+ | `structure_findings` | advisory | ingestion |
497
+ | `fidelity_documents_unverifiable` * (could not be compared) | risk | ingestion |
498
+ | `fidelity_snapshot_coverage` * (below `readiness.min_snapshot_coverage`) | gate | ingestion |
425
499
  | `chunk_integrity_findings` | advisory | ingestion |
426
500
  | `stale_versions`, `stale_versions_unchecked` | advisory | ingestion |
427
501
  | `documents_within_threshold` | advisory | ingestion |
@@ -587,12 +661,13 @@ environments:
587
661
  graphql_mutation: |
588
662
  mutation ($file: Upload!, $metadata: JSON) { uploadDocument(file:$file, metadata:$metadata){ status document_id } }
589
663
  s3:
590
- provider: s3 # s3 | minio | r2 | azure_blob | gcs …
664
+ provider: s3 # s3 | minio | r2 | azure_blob | gcs | local …
591
665
  bucket_name: my-documents
592
666
  prefix: knowledge-base/
593
667
  redis:
594
668
  provider: redis # redis | qdrant | pinecone | pgvector …
595
669
  search_index: my_embeddings
670
+ text_field: text # the field holding chunk text (content, page_content, ...)
596
671
  expected_embedding_dim: 1536
597
672
  expected_distance_metric: COSINE
598
673
  ```
@@ -132,7 +132,8 @@ a knowledge base — they don't turn COMPASS into a retrieval app or an agent-se
132
132
  answer); `compass mcp` is an **inspection surface** (read-only KB tools an agent can call, not
133
133
  a serving layer). Everything here stays on COMPASS's side of the line and never affects a
134
134
  validation pass/fail. They read an `embedding:` block in the project YAML (provider `openai` /
135
- `azure_openai` / `bedrock`, `model_id`, `dimensions`) so a query is embedded the way ingestion was.
135
+ `azure_openai` / `bedrock` / `openai_compatible` for a self-hosted server such as vLLM, Ollama or
136
+ TEI, `model_id`, `dimensions`) so a query is embedded the way ingestion was.
136
137
 
137
138
  ```bash
138
139
  # Ask the KB a question - returns the ranked chunks it would retrieve (no generated answer)
@@ -266,9 +267,15 @@ eval:
266
267
  match: shingle # shingle | exact
267
268
  coverage_min: {default: 0.90, quarterly: 0.97} # keyed by document_type
268
269
  prefer_snapshot: true
270
+ figure_regions: snapshot # snapshot | off: numbers inside figures reported apart
271
+ figure_types: [figure, chart, image] # snapshot element types that are figures
272
+ lost_passages_allowed: 0 # named lost passages tolerated (snapshot baseline)
273
+ figure_words: gate # gate | report: lost words inside figures gate or not
274
+ number_format: "1,234.5" # or "1.234,5" | "1 234,5" | "1'234.5"
269
275
  source_exclusions: # nothing is excluded that is not listed here
270
276
  repeated_on_pages: 5 # headers and footers
271
- min_chars: 75 # small fragments
277
+ min_chars: 75 # small fragments (every element type)
278
+ figure_min_chars: 75 # figure elements this short, dropped by design
272
279
  patterns: ["(?i)^past performance"] # by-design notices
273
280
  page_roles: {disclaimer: "(?i)^important disclosures"}
274
281
  roles: [marginalia, logo, attestation] # read from a snapshot, so they need one
@@ -287,6 +294,16 @@ A document where not one chunk traces to its source is `SOURCE_MISMATCH`: either
287
294
  source key is wrong, or the store holds another document's text under that id. Neither is averaged
288
295
  into coverage as a 0%. A snapshot that cannot be found is reported with the key it was looked for at.
289
296
 
297
+ What gates is what can be named. Against a snapshot, every passage the extractor produced and the
298
+ store lacks is a lost passage, reported with its element type, page and box, and one is enough for
299
+ `CONTENT_LOSS` (`lost_passages_allowed` raises that). A number in body text that is not stored is
300
+ listed with its page and sentence. Numbers inside a figure region, and runs of evenly spaced numbers
301
+ such as an axis (`20.0% 22.0% 24.0%`), are reported apart as `figure_numbers` and never gate; words
302
+ inside a figure are still compared. Page coverage is shown as context, not as a gate. The JSON keeps
303
+ every finding, body text first; the console shows the first few. A caption or a `Source:` note
304
+ stored more than one chunk away from its figure is `CAPTION_DETACHED`, with both chunk ids. A
305
+ source that cannot be read (encrypted, image-only) is compared through its snapshot.
306
+
290
307
  Findings say what is missing, not who lost it, until you declare the extractor's own output. Any
291
308
  extractor that writes JSON works: map its fields once, and each finding becomes `PIPELINE_DROP`,
292
309
  `PIPELINE_ALTER` or `EXTRACTOR_MISS`.
@@ -296,18 +313,68 @@ eval:
296
313
  snapshot:
297
314
  provider: storage_json
298
315
  location: "snapshots/{project}/{id}/{e_tag}/document.json" # also {source_key}
316
+ fallback_locations: ["backup/{e_tag}/document.json"] # tried in order after it
317
+ version: latest_with_elements # current (default) | latest_with_elements
299
318
  format: my_extractor
300
319
  formats:
301
- my_extractor: # dotted paths into the extractor's JSON
302
- elements: "sections"
303
- type: "kind"
320
+ my_extractor: # paths into the extractor's JSON
321
+ elements: "metadata.element_list"
322
+ type: "chunk_type"
304
323
  text: "text"
305
- page: "page"
306
- bbox: "box"
324
+ order: "chunk_index"
325
+ page: "grounding[0].page" # [n] picks one item
326
+ boxes: "grounding[*].box" # [*] takes all: an element may have several boxes
327
+ box_keys: [left, top, right, bottom] # for boxes written as objects
328
+ page_base: 0 # the extractor counts pages from 0
307
329
  cells: "table.cells"
308
- order: "reading_order"
309
330
  ```
310
331
 
332
+ `version: latest_with_elements` reads older object versions when a later write replaced the element
333
+ list with a text-only file, or the key was deleted under bucket versioning. Each document's snapshot
334
+ is `present`, `superseded` (read from an older version or a fallback), `missing`, `wrong_shape` or
335
+ `unreadable`; the counts are in `snapshot_health`, and `readiness.min_snapshot_coverage` (0 to 1)
336
+ fails readiness when too few were read. `compass doctor` reads the snapshots of a few documents,
337
+ says which location and version holds the element list, and prints a `formats` entry to paste when
338
+ the mapping is wrong.
339
+
340
+ A passage the extractor produced and the store lacks is a pipeline drop, and it fails `readiness`
341
+ by default (`fidelity_pipeline_drop`); text missing from the extractor too stays advisory. Table
342
+ elements are compared like any passage, image links (`![name](url)`) and URLs are ignored on every
343
+ side, and a `Source:` line inside a text element is judged as a caption.
344
+
345
+ Structure is checked against the snapshot too, under `eval.structure` (every check reports "not
346
+ checked" when its input is missing): a heading stored with its section, a table in one chunk,
347
+ reading order, every page with text covered by a chunk, the page a chunk states, every source image
348
+ represented by a figure element, and pages whose text layer has no Unicode map. The chunk box and
349
+ chunk type checks run when the index carries those fields (`chunk_box_field`, `chunk_type_field`).
350
+
351
+ Index settings that change what every check reads:
352
+
353
+ ```yaml
354
+ redis:
355
+ text_field: content # the field holding chunk text
356
+ page_base: 0 # the index counts pages from 0; every page is read 1-based
357
+ production_index: kb_merged # the index production queries; reports say when they read another
358
+ coverage: full # every sampled check reads every item (default: sampled)
359
+ triage_file: config/triage.yaml # decisions kept between runs (see below)
360
+ ```
361
+
362
+ **Triage.** `triage_file` lists decisions on findings: `{key, decision: defect | by_design | false,
363
+ reason, owner, expires}`. Every finding carries a stable id and a key (`check|index|document|chunk`,
364
+ globs allowed); `by_design` and `false` never gate, expired entries are ignored with a warning, and
365
+ `compass triage stats` reports each check's precision over the labelled entries. Findings are marked
366
+ new, still open or resolved against the previous run, and `--export-findings DIR` writes one file
367
+ per owner with index, chunk id, chunk index, page and a snippet.
368
+
369
+ **Several indexes.** `discover` lists other indexes in the same store holding the same sources, and
370
+ `compass drift --project P --index-a A --index-b B` reports, per source document, content present
371
+ in one index and missing from the other.
372
+
373
+ **Document metadata.** The opt-in `metadata_checks` step (name it in `pipeline.steps`) checks that
374
+ date fields agree with each other and with the file name, that each document type carries its
375
+ period fields, that a type sits in its folder, and that chunks were ingested after the source last
376
+ changed. Every field, pattern and map is set under `metadata_checks:`.
377
+
311
378
  ### KB readiness
312
379
 
313
380
  `compass readiness --discover D.json [--grounding G.json] [--benchmark B.json] [--drift X.json]
@@ -337,6 +404,7 @@ it changes no verdict.
337
404
  | `corpus_at_risk` | risk | ingestion |
338
405
  | `corpus_verdict_missing` * | risk | ingestion |
339
406
  | `documents_unexamined` * (skipped, pending or empty checks) | risk | ingestion |
407
+ | `checks_not_run` * (a backend such as the PDF reader failed to load) | risk | ingestion |
340
408
  | `partial_run` * (`discover --since`) | risk | ingestion |
341
409
  | `retrieval_query_errors` * | risk | retrieval config |
342
410
  | `retrieval_found_nothing` | risk | retrieval config |
@@ -349,6 +417,12 @@ it changes no verdict.
349
417
  | `fidelity_numbers_missing` | advisory | ingestion |
350
418
  | `fidelity_value_drift` | advisory | ingestion |
351
419
  | `fidelity_source_mismatch` | risk | ingestion |
420
+ | `fidelity_caption_detached` | risk | ingestion |
421
+ | `fidelity_extractor_gap` (source text the extractor did not produce) | advisory | ingestion |
422
+ | `fidelity_pipeline_drop` (passages the extractor produced, missing from the store) | gate | ingestion |
423
+ | `structure_findings` | advisory | ingestion |
424
+ | `fidelity_documents_unverifiable` * (could not be compared) | risk | ingestion |
425
+ | `fidelity_snapshot_coverage` * (below `readiness.min_snapshot_coverage`) | gate | ingestion |
352
426
  | `chunk_integrity_findings` | advisory | ingestion |
353
427
  | `stale_versions`, `stale_versions_unchecked` | advisory | ingestion |
354
428
  | `documents_within_threshold` | advisory | ingestion |
@@ -514,12 +588,13 @@ environments:
514
588
  graphql_mutation: |
515
589
  mutation ($file: Upload!, $metadata: JSON) { uploadDocument(file:$file, metadata:$metadata){ status document_id } }
516
590
  s3:
517
- provider: s3 # s3 | minio | r2 | azure_blob | gcs …
591
+ provider: s3 # s3 | minio | r2 | azure_blob | gcs | local …
518
592
  bucket_name: my-documents
519
593
  prefix: knowledge-base/
520
594
  redis:
521
595
  provider: redis # redis | qdrant | pinecone | pgvector …
522
596
  search_index: my_embeddings
597
+ text_field: text # the field holding chunk text (content, page_content, ...)
523
598
  expected_embedding_dim: 1536
524
599
  expected_distance_metric: COSINE
525
600
  ```
@@ -5,4 +5,4 @@ end-to-end: API upload -> object storage -> knowledge graph -> vector store ->
5
5
  retrieval quality, plus cross-store consistency.
6
6
  """
7
7
 
8
- __version__ = "4.0.2"
8
+ __version__ = "4.2.0"
@@ -390,7 +390,10 @@ def build_alias_map(adapter: Any, fields: list[str], configured: Optional[dict]
390
390
  why so the report can be honest about reduced coverage.
391
391
  """
392
392
  amap = AliasMap(configured=dict(configured or {}))
393
- if adapter is None or not callable(getattr(adapter, "distinct_values", None)):
393
+ # An adapter states whether it can list values; one that predates the flag is trusted when it
394
+ # has the method at all.
395
+ if adapter is None or not getattr(adapter, "enumerates_values",
396
+ callable(getattr(adapter, "distinct_values", None))):
394
397
  amap.note = "backend cannot enumerate distinct values - no aliases derived"
395
398
  return amap
396
399
  names: list[str] = []
@@ -15,6 +15,7 @@ from __future__ import annotations
15
15
  import struct
16
16
  from typing import Any
17
17
 
18
+ from compass.chunk_ref import chunk_ref
18
19
  from compass.config import Settings
19
20
  from compass.providers import get_adapter
20
21
 
@@ -120,6 +121,8 @@ def ask_kb(
120
121
  "s3_key": h.get("s3_key", ""),
121
122
  "text": h.get("text", "") or "",
122
123
  "key": h.get("key", ""),
124
+ "chunk_index": next((h[f] for f in (rc.positional_field, "chunk_index", "position")
125
+ if f and h.get(f) not in (None, "")), ""),
123
126
  "meta": meta,
124
127
  })
125
128
  return {
@@ -128,6 +131,7 @@ def ask_kb(
128
131
  "model": emb_cfg.model_id,
129
132
  "dim": len(vector),
130
133
  "filters": filters or {},
134
+ "index": getattr(rc, "search_index", ""),
131
135
  "results": results,
132
136
  "total": len(results),
133
137
  }
@@ -146,7 +150,11 @@ def format_text(payload: dict, preview: int = 160) -> str:
146
150
  score = r["score"]
147
151
  score_s = f"{float(score):.4f}" if _is_number(score) else str(score)
148
152
  text = " ".join((r["text"] or "").split())
149
- lines.append(f" {r['rank']}. [score {score_s}] {r['file_name']} (chunk {r['chunk_id']})")
153
+ # Index, chunk id and chunk index together: a position alone means different text in
154
+ # another index of the same corpus.
155
+ ref = chunk_ref(payload.get("index", ""), {"key": r.get("key"),
156
+ "chunk_index": r.get("chunk_index", "")})
157
+ lines.append(f" {r['rank']}. [score {score_s}] {r['file_name']} ({ref})")
150
158
  lines.append(f" {text[:preview]}{'...' if len(text) > preview else ''}")
151
159
  if not payload["results"]:
152
160
  lines.append(" (no results - check the index has data and the embedding matches ingestion)")
@@ -183,10 +183,12 @@ def ground_truth_ids(case: dict, cfg: Any) -> set:
183
183
 
184
184
  doc_field = getattr(cfg, "gt_chunk_doc_field", "document_title")
185
185
  page_field = getattr(cfg, "gt_chunk_page_field", "page_start")
186
- found = get_path(case, getattr(cfg, "gt_chunks_path", "context.chunks"))
187
- chunks: list = found if isinstance(found, list) else []
188
- if not chunks and isinstance(case.get("chunks"), list):
189
- chunks = case["chunks"]
186
+ from compass.eval_interop import as_chunks
187
+
188
+ text_field = getattr(cfg, "gt_chunk_text_field", "text") or "text"
189
+ chunks = as_chunks(get_path(case, getattr(cfg, "gt_chunks_path", "context.chunks")), text_field)
190
+ if not chunks:
191
+ chunks = as_chunks(case.get("chunks"), text_field)
190
192
  out = {chunk_identity(c, doc_field, page_field) for c in chunks if isinstance(c, dict)}
191
193
  return {i for i in out if i}
192
194
 
@@ -309,12 +311,57 @@ def _identities(retrieved: list, content: dict, min_containment: float) -> list[
309
311
  return out
310
312
 
311
313
 
314
+ _LENGTH_RATIO = 2.5 # median ground-truth chunk this many times longer or shorter: another index
315
+
316
+
317
+ def eval_index_match(cases: list[dict], cfg: Any, index_chunks: list[dict], *,
318
+ by_content: bool = False) -> dict:
319
+ """Whether the eval's ground truth can be found in this index at all.
320
+
321
+ An eval captured from one index and scored against another reports recall near 0, which
322
+ reads as a retrieval failure. It is not one: the ground-truth chunks name fields this index
323
+ does not have, or were cut to a different size. Checked from the eval's chunks and a sample
324
+ of the index, before any score is read.
325
+
326
+ Returns ``{"matches": bool | None, "reasons": [...]}``; None when it could not be judged.
327
+ """
328
+ from statistics import median
329
+
330
+ from compass.eval_interop import as_chunks, get_path
331
+
332
+ if not index_chunks:
333
+ return {"matches": None, "reasons": ["the index returned no chunks to compare with"]}
334
+ doc_field = getattr(cfg, "gt_chunk_doc_field", "document_title")
335
+ page_field = getattr(cfg, "gt_chunk_page_field", "page_start")
336
+ text_field = getattr(cfg, "gt_chunk_text_field", "text") or "text"
337
+ truth: list[dict] = []
338
+ for case in cases:
339
+ found = get_path(case, getattr(cfg, "gt_chunks_path", "context.chunks"))
340
+ truth += as_chunks(found if found is not None else case.get("chunks"), text_field)
341
+ if not truth:
342
+ return {"matches": None, "reasons": ["the eval carries no ground-truth chunks"]}
343
+ reasons: list[str] = []
344
+ index_fields = {k for c in index_chunks for k, v in c.items() if v not in (None, "")}
345
+ needed = [doc_field] if by_content else [doc_field, page_field]
346
+ for name in needed:
347
+ if any(c.get(name) not in (None, "") for c in truth) and name not in index_fields:
348
+ reasons.append(f"ground-truth chunks are identified by '{name}', which no sampled "
349
+ "chunk of this index carries")
350
+ truth_len = median(len(str(c.get(text_field) or c.get("text") or "")) for c in truth)
351
+ index_len = median(len(str(c.get("text") or "")) for c in index_chunks)
352
+ if truth_len and index_len and not (1 / _LENGTH_RATIO <= truth_len / index_len <= _LENGTH_RATIO):
353
+ reasons.append(f"ground-truth chunks are {truth_len:.0f} characters long at the median, "
354
+ f"this index's {index_len:.0f}: the eval was captured from an index "
355
+ "chunked differently")
356
+ return {"matches": not reasons, "reasons": reasons}
357
+
358
+
312
359
  # --------------------------------------------------------------------------- #
313
360
  # Benchmark run
314
361
  # --------------------------------------------------------------------------- #
315
362
  def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
316
363
  retrieve: Any = None, use_case_filters: bool = True,
317
- match_mode: str = "") -> dict:
364
+ match_mode: str = "", index_sample: Optional[list] = None) -> dict:
318
365
  """Score every strategy over every case. ``retrieve`` is injectable for testing.
319
366
 
320
367
  ``use_case_filters=False`` measures raw vector search over the whole corpus, which is a
@@ -396,6 +443,17 @@ def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
396
443
  def rank(row: dict) -> tuple:
397
444
  return (row.get("ndcg") or 0, row.get("recall") or 0)
398
445
 
446
+ if index_sample is None and retrieve is None:
447
+ try:
448
+ from compass.providers import get_adapter
449
+
450
+ store = get_adapter("vectorstore", settings.redis.provider, config=settings.redis)
451
+ index_sample = store.sample_chunks(50)
452
+ except Exception: # noqa: BLE001 - the comparison is advisory; scores stand without it
453
+ index_sample = []
454
+ match = (eval_index_match([row[0] for row in usable], settings.eval, index_sample,
455
+ by_content=by_content)
456
+ if index_sample is not None else {"matches": None, "reasons": ["not checked"]})
399
457
  winner = max(scored, key=rank, default=None)
400
458
  # An exact tie has no winner. Naming the first-listed strategy would credit config order.
401
459
  if winner is not None and sum(1 for s in scored if rank(s) == rank(winner)) > 1:
@@ -407,6 +465,7 @@ def benchmark(settings: Any, cases: list[dict], strategies: list[Strategy], *,
407
465
  "strategies": per_strategy,
408
466
  "winner": winner["strategy"] if winner else "",
409
467
  "per_query": per_query,
468
+ "eval_index_match": match,
410
469
  "filter_mode": ("disabled" if not use_case_filters else
411
470
  "none-recorded" if not filtered else
412
471
  "per-case" if filtered == len(usable) else "partial"),
@@ -149,9 +149,12 @@ _TEXT: dict[str, dict[str, tuple[str, str, str]]] = {
149
149
  "A degenerate vector cannot be retrieved correctly, and it fails silently.",
150
150
  "Re-embed the document and check the embedding step's output."),
151
151
  "chunk_boundaries": (
152
- "Interior chunk edges fall on sentence boundaries.",
153
- "Chunks cut mid-sentence read poorly. Layout chunkers do this at page edges by design.",
154
- "Tune the splitter if this is fixed-size chunking; otherwise treat it as informational."),
152
+ "No sentence is cut across two chunks on the same page: the first chunk ends without "
153
+ "closing punctuation and not on a heading, and the next continues the sentence.",
154
+ "Each half of the sentence is retrieved without the other. A cut at a page break is "
155
+ "not counted, because layout chunkers end a block there on purpose.",
156
+ "Read the named chunk pairs. Under fixed-size chunking the splits are reported, not "
157
+ "scored."),
155
158
  "content_fidelity": (
156
159
  "Chunk text can be found in the source file on a live run.",
157
160
  "Extraction altered the text, so the KB no longer says what the document says.",
@@ -492,6 +495,18 @@ _TEXT: dict[str, dict[str, tuple[str, str, str]]] = {
492
495
  "or the store holds another document's text under this id.",
493
496
  "Check eval.fidelity.text_field and eval.citation_source_key_fields, then the "
494
497
  "document's chunks."),
498
+ "extractor_gap": (
499
+ "Whether the extractor's output holds all of the source's text.",
500
+ "Text in the source is missing from the extractor's output; the store holds all the "
501
+ "extractor produced, so any loss is before the pipeline.",
502
+ "Compare with a stronger eval.source_extractor first: a weak text layer reads the same "
503
+ "way. Then check the extractor's settings for the missed regions."),
504
+ "caption_detached": (
505
+ "Whether each caption or source note is stored in its figure's chunk or the next one.",
506
+ "A reader retrieving the figure gets it without its source or caption, and the "
507
+ "caption arrives with text it does not describe.",
508
+ "Check the chunker's merge step, which can move a short caption into a neighbour. "
509
+ "Needs eval.snapshot for element types and boxes."),
495
510
  "unverifiable": (
496
511
  "Whether a document or page has text that can be compared at all.",
497
512
  "Nothing was concluded: an image-only page, a garbled text layer or an unreadable "
@@ -543,6 +558,8 @@ _FIDELITY_TITLES = {
543
558
  "numbers_missing": ("Numbers missing", "warn"),
544
559
  "value_drift": ("Value drift", "warn"),
545
560
  "source_mismatch": ("Source mismatch", "warn"),
561
+ "caption_detached": ("Caption detached from its figure", "warn"),
562
+ "extractor_gap": ("Source text missing from the extractor's output", "info"),
546
563
  "unverifiable": ("Unverifiable document or page", "info"),
547
564
  "wrong_page": ("Chunk on the wrong page", "warn"),
548
565
  "altered": ("Chunk altered", "warn"),
@@ -192,6 +192,71 @@ def structure_cuts(texts: list[str]) -> list[dict]:
192
192
  return cuts
193
193
 
194
194
 
195
+ _CONTINUATION_MARKS = ",;:)]"
196
+ # Sentence ends in scripts that write them full width (Chinese, Japanese).
197
+ _WIDE_SENTENCE_END = "\u3002\uff01\uff1f\u2026"
198
+
199
+
200
+ def uncased_share(texts: list[str]) -> float:
201
+ """Share of letters with no upper or lower case (Chinese, Japanese, Thai, Arabic, ...).
202
+
203
+ The sentence-split rule tells a continued sentence by a lowercase opening letter, which these
204
+ scripts do not have, so above half the rule cannot judge the text and must say so.
205
+ """
206
+ letters = [ch for text in texts for ch in text if ch.isalpha()]
207
+ if not letters:
208
+ return 0.0
209
+ return sum(1 for ch in letters if not (ch.isupper() or ch.islower())) / len(letters)
210
+ _HEADING_WORDS = 10
211
+
212
+
213
+ def _heading_like(line: str) -> bool:
214
+ """A short line in title or upper case, or a markdown heading: a chunk may end on it."""
215
+ line = line.strip()
216
+ if _HEADING.match(line):
217
+ return True
218
+ words = [w for w in re.findall(r"[^\W\d_][\w'-]*", line)]
219
+ if not words or len(words) > _HEADING_WORDS:
220
+ return False
221
+ capitalised = sum(1 for w in words if w[0].isupper())
222
+ return capitalised / len(words) >= 0.6
223
+
224
+
225
+ def sentence_splits(texts: list[str], pages: list | None = None) -> list[dict]:
226
+ """Boundaries that cut one sentence in two on the same page.
227
+
228
+ ``texts`` are a document's chunks in order and ``pages`` their ``(first, last)`` pages,
229
+ when known. A boundary is a split when the first chunk ends without closing punctuation,
230
+ its last line is not a heading, the next chunk opens by continuing the sentence (a
231
+ lowercase letter, or a comma, semicolon or closing bracket), and both sides are on one
232
+ page, so a page break, which layout chunkers keep on purpose, never counts. Tables, lists
233
+ and code are left to the structure checks.
234
+
235
+ Returns ``[{"boundary": i, "page": p}]``, where ``i`` is the first chunk's position.
236
+ """
237
+ out: list[dict] = []
238
+ for i, (left, right) in enumerate(zip(texts, texts[1:])):
239
+ left_lines, right_lines = _content_lines(left), _content_lines(right)
240
+ if not left_lines or not right_lines:
241
+ continue
242
+ tail, head = left_lines[-1].rstrip(), right_lines[0].lstrip()
243
+ if (tail[-1] in _SENTENCE_END or tail[-1] in _WIDE_SENTENCE_END
244
+ or tail.endswith(("|", "```")) or _PIPE_ROW.match(tail)
245
+ or _LIST_ITEM.match(tail) or _heading_like(tail)):
246
+ continue
247
+ if (not (head[0].islower() or head[0] in _CONTINUATION_MARKS) or _PIPE_ROW.match(head)
248
+ or _LIST_ITEM.match(head)):
249
+ continue
250
+ page = None
251
+ if pages and i + 1 < len(pages):
252
+ left_end, right_start = pages[i][1], pages[i + 1][0]
253
+ if left_end is not None and right_start is not None and left_end != right_start:
254
+ continue # the cut falls at a page break
255
+ page = left_end if left_end is not None else right_start
256
+ out.append({"boundary": i, "page": page, "tail": tail[-60:], "head": head[:60]})
257
+ return out
258
+
259
+
195
260
  def infer_chunking(texts: list[str], *, summary_populated: bool, min_chunks: int,
196
261
  min_spread: float) -> tuple[bool, str]:
197
262
  """Do these chunks look clearly not fixed-size? Returns (non_fixed, evidence).