biblicus 0.10.0__tar.gz → 0.12.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 (235) hide show
  1. {biblicus-0.10.0/src/biblicus.egg-info → biblicus-0.12.0}/PKG-INFO +7 -1
  2. {biblicus-0.10.0 → biblicus-0.12.0}/README.md +6 -0
  3. {biblicus-0.10.0 → biblicus-0.12.0}/docs/ARCHITECTURE.md +4 -4
  4. {biblicus-0.10.0 → biblicus-0.12.0}/docs/CONTEXT_PACK.md +37 -1
  5. {biblicus-0.10.0 → biblicus-0.12.0}/docs/CORPUS_DESIGN.md +2 -2
  6. {biblicus-0.10.0 → biblicus-0.12.0}/docs/DEMOS.md +3 -3
  7. {biblicus-0.10.0 → biblicus-0.12.0}/docs/FEATURE_INDEX.md +1 -0
  8. biblicus-0.12.0/docs/RETRIEVAL.md +47 -0
  9. biblicus-0.12.0/docs/RETRIEVAL_EVALUATION.md +74 -0
  10. biblicus-0.12.0/docs/RETRIEVAL_QUALITY.md +42 -0
  11. {biblicus-0.10.0 → biblicus-0.12.0}/docs/ROADMAP.md +15 -22
  12. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/pass-through.md +3 -3
  13. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/unstructured.md +1 -1
  14. {biblicus-0.10.0 → biblicus-0.12.0}/docs/index.rst +3 -0
  15. {biblicus-0.10.0 → biblicus-0.12.0}/features/context_pack_cli.feature +25 -0
  16. biblicus-0.12.0/features/context_pack_policies.feature +92 -0
  17. biblicus-0.12.0/features/retrieval_quality.feature +253 -0
  18. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/cli_steps.py +51 -0
  19. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/context_pack_steps.py +88 -0
  20. biblicus-0.12.0/features/steps/retrieval_quality_steps.py +186 -0
  21. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/retrieval_steps.py +10 -0
  22. {biblicus-0.10.0 → biblicus-0.12.0}/pyproject.toml +1 -1
  23. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/__init__.py +1 -1
  24. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/profiling.py +1 -1
  25. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/backends/__init__.py +4 -0
  26. biblicus-0.12.0/src/biblicus/backends/hybrid.py +284 -0
  27. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/backends/sqlite_full_text_search.py +264 -18
  28. biblicus-0.12.0/src/biblicus/backends/vector.py +460 -0
  29. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/cli.py +30 -1
  30. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/context.py +138 -4
  31. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/models.py +3 -0
  32. {biblicus-0.10.0 → biblicus-0.12.0/src/biblicus.egg-info}/PKG-INFO +7 -1
  33. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus.egg-info/SOURCES.txt +8 -0
  34. {biblicus-0.10.0 → biblicus-0.12.0}/LICENSE +0 -0
  35. {biblicus-0.10.0 → biblicus-0.12.0}/MANIFEST.in +0 -0
  36. {biblicus-0.10.0 → biblicus-0.12.0}/THIRD_PARTY_NOTICES.md +0 -0
  37. {biblicus-0.10.0 → biblicus-0.12.0}/datasets/wikipedia_mini.json +0 -0
  38. {biblicus-0.10.0 → biblicus-0.12.0}/docs/ANALYSIS.md +0 -0
  39. {biblicus-0.10.0 → biblicus-0.12.0}/docs/BACKENDS.md +0 -0
  40. {biblicus-0.10.0 → biblicus-0.12.0}/docs/CORPUS.md +0 -0
  41. {biblicus-0.10.0 → biblicus-0.12.0}/docs/EXTRACTION.md +0 -0
  42. {biblicus-0.10.0 → biblicus-0.12.0}/docs/KNOWLEDGE_BASE.md +0 -0
  43. {biblicus-0.10.0 → biblicus-0.12.0}/docs/PROFILING.md +0 -0
  44. {biblicus-0.10.0 → biblicus-0.12.0}/docs/STT.md +0 -0
  45. {biblicus-0.10.0 → biblicus-0.12.0}/docs/TESTING.md +0 -0
  46. {biblicus-0.10.0 → biblicus-0.12.0}/docs/TOPIC_MODELING.md +0 -0
  47. {biblicus-0.10.0 → biblicus-0.12.0}/docs/USER_CONFIGURATION.md +0 -0
  48. {biblicus-0.10.0 → biblicus-0.12.0}/docs/api.rst +0 -0
  49. {biblicus-0.10.0 → biblicus-0.12.0}/docs/backends/index.md +0 -0
  50. {biblicus-0.10.0 → biblicus-0.12.0}/docs/backends/scan.md +0 -0
  51. {biblicus-0.10.0 → biblicus-0.12.0}/docs/backends/sqlite-full-text-search.md +0 -0
  52. {biblicus-0.10.0 → biblicus-0.12.0}/docs/conf.py +0 -0
  53. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/index.md +0 -0
  54. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/ocr/index.md +0 -0
  55. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/ocr/paddleocr-vl.md +0 -0
  56. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/ocr/rapidocr.md +0 -0
  57. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/index.md +0 -0
  58. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/pipeline.md +0 -0
  59. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/select-longest.md +0 -0
  60. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/select-override.md +0 -0
  61. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/select-smart-override.md +0 -0
  62. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/pipeline-utilities/select-text.md +0 -0
  63. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/speech-to-text/deepgram.md +0 -0
  64. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/speech-to-text/index.md +0 -0
  65. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/speech-to-text/openai.md +0 -0
  66. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/index.md +0 -0
  67. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/markitdown.md +0 -0
  68. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/metadata.md +0 -0
  69. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/text-document/pdf.md +0 -0
  70. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/vlm-document/docling-granite.md +0 -0
  71. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/vlm-document/docling-smol.md +0 -0
  72. {biblicus-0.10.0 → biblicus-0.12.0}/docs/extractors/vlm-document/index.md +0 -0
  73. {biblicus-0.10.0 → biblicus-0.12.0}/features/analysis_schema.feature +0 -0
  74. {biblicus-0.10.0 → biblicus-0.12.0}/features/backend_validation.feature +0 -0
  75. {biblicus-0.10.0 → biblicus-0.12.0}/features/biblicus_corpus.feature +0 -0
  76. {biblicus-0.10.0 → biblicus-0.12.0}/features/cli_entrypoint.feature +0 -0
  77. {biblicus-0.10.0 → biblicus-0.12.0}/features/cli_parsing.feature +0 -0
  78. {biblicus-0.10.0 → biblicus-0.12.0}/features/cli_step_spec_parsing.feature +0 -0
  79. {biblicus-0.10.0 → biblicus-0.12.0}/features/content_sniffing.feature +0 -0
  80. {biblicus-0.10.0 → biblicus-0.12.0}/features/context_pack.feature +0 -0
  81. {biblicus-0.10.0 → biblicus-0.12.0}/features/corpus_edge_cases.feature +0 -0
  82. {biblicus-0.10.0 → biblicus-0.12.0}/features/corpus_identity.feature +0 -0
  83. {biblicus-0.10.0 → biblicus-0.12.0}/features/corpus_purge.feature +0 -0
  84. {biblicus-0.10.0 → biblicus-0.12.0}/features/crawl.feature +0 -0
  85. {biblicus-0.10.0 → biblicus-0.12.0}/features/docling_granite_extractor.feature +0 -0
  86. {biblicus-0.10.0 → biblicus-0.12.0}/features/docling_smol_extractor.feature +0 -0
  87. {biblicus-0.10.0 → biblicus-0.12.0}/features/environment.py +0 -0
  88. {biblicus-0.10.0 → biblicus-0.12.0}/features/error_cases.feature +0 -0
  89. {biblicus-0.10.0 → biblicus-0.12.0}/features/evaluation.feature +0 -0
  90. {biblicus-0.10.0 → biblicus-0.12.0}/features/evidence_processing.feature +0 -0
  91. {biblicus-0.10.0 → biblicus-0.12.0}/features/extraction_error_handling.feature +0 -0
  92. {biblicus-0.10.0 → biblicus-0.12.0}/features/extraction_run_lifecycle.feature +0 -0
  93. {biblicus-0.10.0 → biblicus-0.12.0}/features/extraction_selection.feature +0 -0
  94. {biblicus-0.10.0 → biblicus-0.12.0}/features/extraction_selection_longest.feature +0 -0
  95. {biblicus-0.10.0 → biblicus-0.12.0}/features/extractor_pipeline.feature +0 -0
  96. {biblicus-0.10.0 → biblicus-0.12.0}/features/extractor_validation.feature +0 -0
  97. {biblicus-0.10.0 → biblicus-0.12.0}/features/frontmatter.feature +0 -0
  98. {biblicus-0.10.0 → biblicus-0.12.0}/features/hook_config_validation.feature +0 -0
  99. {biblicus-0.10.0 → biblicus-0.12.0}/features/hook_error_handling.feature +0 -0
  100. {biblicus-0.10.0 → biblicus-0.12.0}/features/import_tree.feature +0 -0
  101. {biblicus-0.10.0 → biblicus-0.12.0}/features/inference_backend.feature +0 -0
  102. {biblicus-0.10.0 → biblicus-0.12.0}/features/ingest_sources.feature +0 -0
  103. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_audio_samples.feature +0 -0
  104. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_image_samples.feature +0 -0
  105. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_mixed_corpus.feature +0 -0
  106. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_mixed_extraction.feature +0 -0
  107. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_ocr_image_extraction.feature +0 -0
  108. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_pdf_retrieval.feature +0 -0
  109. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_pdf_samples.feature +0 -0
  110. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_unstructured_extraction.feature +0 -0
  111. {biblicus-0.10.0 → biblicus-0.12.0}/features/integration_wikipedia.feature +0 -0
  112. {biblicus-0.10.0 → biblicus-0.12.0}/features/knowledge_base.feature +0 -0
  113. {biblicus-0.10.0 → biblicus-0.12.0}/features/lifecycle_hooks.feature +0 -0
  114. {biblicus-0.10.0 → biblicus-0.12.0}/features/markitdown_extractor.feature +0 -0
  115. {biblicus-0.10.0 → biblicus-0.12.0}/features/model_validation.feature +0 -0
  116. {biblicus-0.10.0 → biblicus-0.12.0}/features/ocr_extractor.feature +0 -0
  117. {biblicus-0.10.0 → biblicus-0.12.0}/features/paddleocr_vl_extractor.feature +0 -0
  118. {biblicus-0.10.0 → biblicus-0.12.0}/features/paddleocr_vl_parse_api_response.feature +0 -0
  119. {biblicus-0.10.0 → biblicus-0.12.0}/features/pdf_text_extraction.feature +0 -0
  120. {biblicus-0.10.0 → biblicus-0.12.0}/features/profiling.feature +0 -0
  121. {biblicus-0.10.0 → biblicus-0.12.0}/features/python_api.feature +0 -0
  122. {biblicus-0.10.0 → biblicus-0.12.0}/features/python_hook_logging.feature +0 -0
  123. {biblicus-0.10.0 → biblicus-0.12.0}/features/query_processing.feature +0 -0
  124. {biblicus-0.10.0 → biblicus-0.12.0}/features/recipe_file_extraction.feature +0 -0
  125. {biblicus-0.10.0 → biblicus-0.12.0}/features/retrieval_budget.feature +0 -0
  126. {biblicus-0.10.0 → biblicus-0.12.0}/features/retrieval_scan.feature +0 -0
  127. {biblicus-0.10.0 → biblicus-0.12.0}/features/retrieval_sqlite_full_text_search.feature +0 -0
  128. {biblicus-0.10.0 → biblicus-0.12.0}/features/retrieval_uses_extraction_run.feature +0 -0
  129. {biblicus-0.10.0 → biblicus-0.12.0}/features/retrieval_utilities.feature +0 -0
  130. {biblicus-0.10.0 → biblicus-0.12.0}/features/select_override.feature +0 -0
  131. {biblicus-0.10.0 → biblicus-0.12.0}/features/smart_override_selection.feature +0 -0
  132. {biblicus-0.10.0 → biblicus-0.12.0}/features/source_loading.feature +0 -0
  133. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/analysis_steps.py +0 -0
  134. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/backend_steps.py +0 -0
  135. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/cli_parsing_steps.py +0 -0
  136. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/crawl_steps.py +0 -0
  137. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/deepgram_steps.py +0 -0
  138. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/docling_steps.py +0 -0
  139. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/evidence_processing_steps.py +0 -0
  140. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/extraction_run_lifecycle_steps.py +0 -0
  141. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/extraction_steps.py +0 -0
  142. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/extractor_steps.py +0 -0
  143. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/frontmatter_steps.py +0 -0
  144. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/inference_steps.py +0 -0
  145. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/knowledge_base_steps.py +0 -0
  146. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/markitdown_steps.py +0 -0
  147. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/model_steps.py +0 -0
  148. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/openai_steps.py +0 -0
  149. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/paddleocr_mock_steps.py +0 -0
  150. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/paddleocr_vl_steps.py +0 -0
  151. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/paddleocr_vl_unit_steps.py +0 -0
  152. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/pdf_steps.py +0 -0
  153. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/profiling_steps.py +0 -0
  154. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/python_api_steps.py +0 -0
  155. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/rapidocr_steps.py +0 -0
  156. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/requests_mock_steps.py +0 -0
  157. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/stt_deepgram_steps.py +0 -0
  158. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/stt_steps.py +0 -0
  159. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/topic_modeling_steps.py +0 -0
  160. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/unstructured_steps.py +0 -0
  161. {biblicus-0.10.0 → biblicus-0.12.0}/features/steps/user_config_steps.py +0 -0
  162. {biblicus-0.10.0 → biblicus-0.12.0}/features/streaming_ingest.feature +0 -0
  163. {biblicus-0.10.0 → biblicus-0.12.0}/features/stt_deepgram_extractor.feature +0 -0
  164. {biblicus-0.10.0 → biblicus-0.12.0}/features/stt_extractor.feature +0 -0
  165. {biblicus-0.10.0 → biblicus-0.12.0}/features/text_extraction_runs.feature +0 -0
  166. {biblicus-0.10.0 → biblicus-0.12.0}/features/token_budget.feature +0 -0
  167. {biblicus-0.10.0 → biblicus-0.12.0}/features/topic_modeling.feature +0 -0
  168. {biblicus-0.10.0 → biblicus-0.12.0}/features/unstructured_extractor.feature +0 -0
  169. {biblicus-0.10.0 → biblicus-0.12.0}/features/user_config.feature +0 -0
  170. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_ag_news.py +0 -0
  171. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_audio_samples.py +0 -0
  172. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_image_samples.py +0 -0
  173. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_mixed_samples.py +0 -0
  174. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_pdf_samples.py +0 -0
  175. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/download_wikipedia.py +0 -0
  176. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/profiling_demo.py +0 -0
  177. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/readme_end_to_end_demo.py +0 -0
  178. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/test.py +0 -0
  179. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/topic_modeling_integration.py +0 -0
  180. {biblicus-0.10.0 → biblicus-0.12.0}/scripts/wikipedia_rag_demo.py +0 -0
  181. {biblicus-0.10.0 → biblicus-0.12.0}/setup.cfg +0 -0
  182. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/__main__.py +0 -0
  183. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/_vendor/dotyaml/__init__.py +0 -0
  184. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/_vendor/dotyaml/interpolation.py +0 -0
  185. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/_vendor/dotyaml/loader.py +0 -0
  186. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/_vendor/dotyaml/transformer.py +0 -0
  187. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/__init__.py +0 -0
  188. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/base.py +0 -0
  189. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/llm.py +0 -0
  190. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/models.py +0 -0
  191. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/schema.py +0 -0
  192. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/analysis/topic_modeling.py +0 -0
  193. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/backends/base.py +0 -0
  194. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/backends/scan.py +0 -0
  195. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/constants.py +0 -0
  196. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/corpus.py +0 -0
  197. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/crawl.py +0 -0
  198. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/errors.py +0 -0
  199. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/evaluation.py +0 -0
  200. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/evidence_processing.py +0 -0
  201. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extraction.py +0 -0
  202. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/__init__.py +0 -0
  203. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/base.py +0 -0
  204. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/deepgram_stt.py +0 -0
  205. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/docling_granite_text.py +0 -0
  206. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/docling_smol_text.py +0 -0
  207. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/markitdown_text.py +0 -0
  208. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/metadata_text.py +0 -0
  209. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/openai_stt.py +0 -0
  210. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/paddleocr_vl_text.py +0 -0
  211. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/pass_through_text.py +0 -0
  212. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/pdf_text.py +0 -0
  213. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/pipeline.py +0 -0
  214. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/rapidocr_text.py +0 -0
  215. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/select_longest_text.py +0 -0
  216. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/select_override.py +0 -0
  217. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/select_smart_override.py +0 -0
  218. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/select_text.py +0 -0
  219. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/extractors/unstructured_text.py +0 -0
  220. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/frontmatter.py +0 -0
  221. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/hook_logging.py +0 -0
  222. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/hook_manager.py +0 -0
  223. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/hooks.py +0 -0
  224. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/ignore.py +0 -0
  225. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/inference.py +0 -0
  226. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/knowledge_base.py +0 -0
  227. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/retrieval.py +0 -0
  228. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/sources.py +0 -0
  229. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/time.py +0 -0
  230. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/uris.py +0 -0
  231. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus/user_config.py +0 -0
  232. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus.egg-info/dependency_links.txt +0 -0
  233. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus.egg-info/entry_points.txt +0 -0
  234. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus.egg-info/requires.txt +0 -0
  235. {biblicus-0.10.0 → biblicus-0.12.0}/src/biblicus.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: biblicus
3
- Version: 0.10.0
3
+ Version: 0.12.0
4
4
  Summary: Command line interface and Python library for corpus ingestion, retrieval, and evaluation.
5
5
  License: MIT
6
6
  Requires-Python: >=3.9
@@ -493,6 +493,12 @@ Two backends are included.
493
493
 
494
494
  For detailed documentation including configuration options, performance characteristics, and usage examples, see the [Backend Reference][backend-reference].
495
495
 
496
+ ## Retrieval documentation
497
+
498
+ For the retrieval pipeline overview and run artifacts, see `docs/RETRIEVAL.md`. For retrieval quality upgrades
499
+ (tuned lexical baseline, reranking, hybrid retrieval), see `docs/RETRIEVAL_QUALITY.md`. For evaluation workflows
500
+ and dataset formats, see `docs/RETRIEVAL_EVALUATION.md`.
501
+
496
502
  ## Extraction backends
497
503
 
498
504
  These extractors are built in. Optional ones require extra dependencies. See [text extraction documentation][text-extraction] for details.
@@ -447,6 +447,12 @@ Two backends are included.
447
447
 
448
448
  For detailed documentation including configuration options, performance characteristics, and usage examples, see the [Backend Reference][backend-reference].
449
449
 
450
+ ## Retrieval documentation
451
+
452
+ For the retrieval pipeline overview and run artifacts, see `docs/RETRIEVAL.md`. For retrieval quality upgrades
453
+ (tuned lexical baseline, reranking, hybrid retrieval), see `docs/RETRIEVAL_QUALITY.md`. For evaluation workflows
454
+ and dataset formats, see `docs/RETRIEVAL_EVALUATION.md`.
455
+
450
456
  ## Extraction backends
451
457
 
452
458
  These extractors are built in. Optional ones require extra dependencies. See [text extraction documentation][text-extraction] for details.
@@ -88,11 +88,11 @@ Evidence is the canonical output of retrieval. Required fields:
88
88
  ### Integration boundary
89
89
 
90
90
  - Biblicus can integrate with Tactus as a **Model Context Protocol toolset**, for example with tool names such as `knowledge_base_ingest`, `knowledge_base_query`, and `knowledge_base_stats`.
91
- - We will **not** add a knowledge base or retrieval augmented generation language primitive in version zero. Revisit only if we need semantics that tools cannot express cleanly, such as enforceable policy boundaries, runtime managed durability, caching hooks, or guaranteed instrumentation.
91
+ - We do **not** add a knowledge base or retrieval augmented generation language primitive in version zero. Revisit only if we need semantics that tools cannot express cleanly, such as enforceable policy boundaries, runtime managed durability, caching hooks, or guaranteed instrumentation.
92
92
 
93
93
  ### Interface packaging
94
94
 
95
- - The knowledge base interface is a **small protocol and reference implementation**, including tool schemas and a reference Model Context Protocol server. We will not build a full managed service in version zero.
95
+ - The knowledge base interface is a **small protocol and reference implementation**, including tool schemas and a reference Model Context Protocol server. We do not build a full managed service in version zero.
96
96
 
97
97
  ### Corpus identity and layout
98
98
 
@@ -143,7 +143,7 @@ The interface stays the same; topology is configuration.
143
143
  - When a backend produces persisted materializations, Biblicus treats them as **versioned build runs** identified by `run_id` (rather than overwriting in place by default).
144
144
  - Manifests exist even for just-in-time backends (materializations may be empty).
145
145
  - Full directed acyclic graph lineage is not included in version zero; revisit only if needed.
146
- - Future (optional): define **shared materialization formats** (canonical chunk and embedding stores) so multiple backends can reuse intermediates when it makes sense; keep it opt-in.
146
+ - Optional: define **shared materialization formats** (canonical chunk and embedding stores) so multiple backends can reuse intermediates when it makes sense; keep it opt-in.
147
147
 
148
148
  ### Evaluation
149
149
 
@@ -156,7 +156,7 @@ The interface stays the same; topology is configuration.
156
156
  - The corpus catalog is **file-based** (committable, portable, backend-agnostic) so any backend/tool can consume it without requiring a database engine.
157
157
  - Canonical version zero format is a single JavaScript Object Notation file at `.biblicus/catalog.json`, written atomically (temporary file and rename) on updates.
158
158
  - The catalog includes `latest_run_id` and run manifests are stored at `.biblicus/runs/<run_id>.json`.
159
- - If this ever becomes a bottleneck at very large scales, we will **change the specification** (bump `schema_version`) rather than introduce multiple “supported” catalog storage modes.
159
+ - If this becomes a bottleneck at very large scales, we **change the specification** (bump `schema_version`) rather than introduce multiple “supported” catalog storage modes.
160
160
 
161
161
  ## Near-term deliverables
162
162
 
@@ -23,13 +23,49 @@ context_pack = build_context_pack(result, policy=policy)
23
23
  print(context_pack.text)
24
24
  ```
25
25
 
26
+ ## Policy surfaces
27
+
28
+ Context pack policies make ordering and formatting explicit.
29
+
30
+ ### Ordering
31
+
32
+ Use `ordering` to control how evidence blocks are arranged before joining:
33
+
34
+ - `rank`: use the evidence rank as provided by retrieval.
35
+ - `score`: sort by score (descending) and then item identifier.
36
+ - `source`: group by source uniform resource identifier, then sort by score.
37
+
38
+ ### Metadata inclusion
39
+
40
+ Set `include_metadata=True` to prepend metadata to each block. Metadata includes:
41
+
42
+ - `item_id`
43
+ - `source_uri`
44
+ - `score`
45
+ - `stage`
46
+
47
+ ### Character budgets
48
+
49
+ Character budgets drop trailing blocks until the context pack fits the specified limit. This keeps context shaping
50
+ deterministic without relying on a tokenizer.
51
+
52
+ In Python:
53
+
54
+ ```python
55
+ from biblicus.context import CharacterBudget, ContextPackPolicy, fit_context_pack_to_character_budget
56
+
57
+ policy = ContextPackPolicy(join_with="\n\n", ordering="score", include_metadata=True)
58
+ fitted = fit_context_pack_to_character_budget(context_pack, policy=policy, character_budget=CharacterBudget(max_characters=500))
59
+ print(fitted.text)
60
+ ```
61
+
26
62
  ## Command-line interface
27
63
 
28
64
  The command-line interface can build a context pack from a retrieval result by reading JavaScript Object Notation from standard input.
29
65
 
30
66
  ```bash
31
67
  biblicus query --corpus corpora/example --query "primary button style preference" \\
32
- | biblicus context-pack build
68
+ | biblicus context-pack build --ordering score --include-metadata --max-characters 500
33
69
  ```
34
70
 
35
71
  ## What context pack building does
@@ -216,7 +216,7 @@ Version zero locked this as policy. A prune workflow was not implemented yet.
216
216
 
217
217
  Goal: retain derived artifacts from multiple implementations side by side so a user can compare results and switch between implementations without losing work.
218
218
 
219
- This decision applies to extraction plugins and retrieval backends, and to any future plugin type that produces derived artifacts.
219
+ This decision applies to extraction plugins and retrieval backends, and to any plugin type that produces derived artifacts.
220
220
 
221
221
  Option A: store artifacts under the corpus, partitioned by plugin type
222
222
 
@@ -369,7 +369,7 @@ Version zero implemented option A by writing structured log entries for hook exe
369
369
 
370
370
  ## Outcomes and remaining questions
371
371
 
372
- The hook protocol and hook logging policy above were implemented in version zero. This section records what was implemented, plus the questions that remain for future iterations.
372
+ The hook protocol and hook logging policy above were implemented in version zero. This section records what was implemented and the open questions tracked for later iterations.
373
373
 
374
374
  ### Hook contexts implemented in version zero
375
375
 
@@ -6,7 +6,7 @@ For the ordered plan of what to build next, see `docs/ROADMAP.md`.
6
6
 
7
7
  ## Diagram of the current system and the next layers
8
8
 
9
- Blue boxes are implemented now. Purple boxes are planned next layers that we can build and compare.
9
+ Blue boxes are implemented now. Purple boxes are layers not implemented yet that we can build and compare.
10
10
 
11
11
  ```mermaid
12
12
  %%{init: {"flowchart": {"useMaxWidth": true, "nodeSpacing": 18, "rankSpacing": 22}}}%%
@@ -233,7 +233,7 @@ python3 -m biblicus extract build --corpus corpora/demo \\
233
233
  --step select-text
234
234
  ```
235
235
 
236
- Copy the `run_id` from the JavaScript Object Notation output. You will use it as `EXTRACTION_RUN_ID` in the next command.
236
+ Copy the `run_id` from the JavaScript Object Notation output. Use it as `EXTRACTION_RUN_ID` in the next command.
237
237
 
238
238
  ```
239
239
  python3 -m biblicus build --corpus corpora/demo --backend sqlite-full-text-search \\
@@ -251,7 +251,7 @@ python3 scripts/download_pdf_samples.py --corpus corpora/pdf_samples --force
251
251
  python3 -m biblicus extract build --corpus corpora/pdf_samples --step pdf-text
252
252
  ```
253
253
 
254
- Copy the `run_id` from the JavaScript Object Notation output. You will use it as `PDF_EXTRACTION_RUN_ID` in the next command.
254
+ Copy the `run_id` from the JavaScript Object Notation output. Use it as `PDF_EXTRACTION_RUN_ID` in the next command.
255
255
 
256
256
  ```
257
257
  python3 -m biblicus build --corpus corpora/pdf_samples --backend sqlite-full-text-search --config extraction_run=pipeline:PDF_EXTRACTION_RUN_ID --config chunk_size=200 --config chunk_overlap=50 --config snippet_characters=120
@@ -204,6 +204,7 @@ Documentation:
204
204
  Behavior specifications:
205
205
 
206
206
  - `features/context_pack.feature`
207
+ - `features/context_pack_policies.feature`
207
208
  - `features/token_budget.feature`
208
209
 
209
210
  Primary implementation:
@@ -0,0 +1,47 @@
1
+ # Retrieval
2
+
3
+ Biblicus treats retrieval as a reproducible, explicit pipeline stage that transforms a corpus into structured evidence.
4
+ Retrieval is separated from extraction and context shaping so each can be evaluated independently and swapped without
5
+ rewriting ingestion.
6
+
7
+ ## Retrieval concepts
8
+
9
+ - **Backend**: a pluggable retrieval implementation that can build and query runs.
10
+ - **Run**: a recorded retrieval build for a corpus and extraction run.
11
+ - **Evidence**: structured output containing identifiers, provenance, and scores.
12
+ - **Stage**: explicit steps such as retrieve, rerank, and filter.
13
+
14
+ ## How retrieval runs work
15
+
16
+ 1) Ingest raw items into a corpus.
17
+ 2) Build an extraction run to produce text artifacts.
18
+ 3) Build a retrieval run with a backend, referencing the extraction run.
19
+ 4) Query the run to return evidence.
20
+
21
+ Retrieval runs are stored under:
22
+
23
+ ```
24
+ .biblicus/runs/retrieval/<backend_id>/<run_id>/
25
+ ```
26
+
27
+ ## Backends
28
+
29
+ See `docs/backends/index.md` for backend selection and configuration.
30
+
31
+ ## Evaluation
32
+
33
+ Retrieval runs are evaluated against datasets with explicit budgets. See `docs/RETRIEVAL_EVALUATION.md` for the
34
+ dataset format and workflow, `docs/FEATURE_INDEX.md` for the behavior specifications, and `docs/CONTEXT_PACK.md` for
35
+ how evidence feeds into context packs.
36
+
37
+ ## Why the separation matters
38
+
39
+ Keeping extraction and retrieval distinct makes it possible to:
40
+
41
+ - Reuse the same extracted artifacts across many retrieval backends.
42
+ - Compare backends against the same corpus and dataset inputs.
43
+ - Record and audit retrieval decisions without mixing in prompting or context formatting.
44
+
45
+ ## Retrieval quality
46
+
47
+ For retrieval quality upgrades, see `docs/RETRIEVAL_QUALITY.md`.
@@ -0,0 +1,74 @@
1
+ # Retrieval evaluation
2
+
3
+ Biblicus evaluates retrieval runs against deterministic datasets so quality comparisons are repeatable across backends
4
+ and corpora. Evaluations keep the evidence-first model intact by reporting per-query evidence alongside summary
5
+ metrics.
6
+
7
+ ## Dataset format
8
+
9
+ Retrieval datasets are stored as JavaScript Object Notation files with a strict schema:
10
+
11
+ ```json
12
+ {
13
+ "schema_version": 1,
14
+ "name": "example-dataset",
15
+ "description": "Small hand-labeled dataset for smoke tests.",
16
+ "queries": [
17
+ {
18
+ "query_id": "q-001",
19
+ "query_text": "alpha",
20
+ "expected_item_id": "item-id-123",
21
+ "kind": "gold"
22
+ }
23
+ ]
24
+ }
25
+ ```
26
+
27
+ Each query includes either an `expected_item_id` or an `expected_source_uri`. The `kind` field records whether the
28
+ query is hand-labeled (`gold`) or synthetic.
29
+
30
+ ## Running an evaluation
31
+
32
+ Use the command-line interface to evaluate a retrieval run against a dataset:
33
+
34
+ ```bash
35
+ biblicus eval --corpus corpora/example --run <run_id> --dataset datasets/retrieval.json \
36
+ --max-total-items 5 --max-total-characters 2000 --max-items-per-source 5
37
+ ```
38
+
39
+ If `--run` is omitted, the latest retrieval run is used. Evaluations are deterministic for the same corpus, run, and
40
+ budget.
41
+
42
+ ## Output
43
+
44
+ The evaluation output includes:
45
+
46
+ - Dataset metadata (name, description, query count).
47
+ - Run metadata (backend ID, run ID, evaluation timestamp).
48
+ - Metrics (hit rate, precision-at-k, mean reciprocal rank).
49
+ - System diagnostics (latency percentiles and index size).
50
+
51
+ The output is JavaScript Object Notation suitable for downstream reporting.
52
+
53
+ ## Python usage
54
+
55
+ ```python
56
+ from pathlib import Path
57
+
58
+ from biblicus.corpus import Corpus
59
+ from biblicus.evaluation import evaluate_run, load_dataset
60
+ from biblicus.models import QueryBudget
61
+
62
+ corpus = Corpus.open("corpora/example")
63
+ run = corpus.load_run("<run_id>")
64
+ dataset = load_dataset(Path("datasets/retrieval.json"))
65
+ budget = QueryBudget(max_total_items=5, max_total_characters=2000, max_items_per_source=5)
66
+ result = evaluate_run(corpus=corpus, run=run, dataset=dataset, budget=budget)
67
+ print(result.model_dump_json(indent=2))
68
+ ```
69
+
70
+ ## Design notes
71
+
72
+ - Evaluation is reproducible by construction: the run manifest, dataset, and budget fully determine the results.
73
+ - The evaluation workflow expects retrieval stages to remain explicit in the run artifacts.
74
+ - Reports are portable, so comparisons across backends and corpora are straightforward.
@@ -0,0 +1,42 @@
1
+ # Retrieval quality upgrades
2
+
3
+ This document describes the retrieval quality upgrades available in Biblicus. It is a reference for how retrieval
4
+ quality is expressed in runs and how to interpret the signals in artifacts and evidence.
5
+
6
+ ## Goals
7
+
8
+ - Improve relevance without losing determinism or reproducibility.
9
+ - Keep retrieval stages explicit and visible in run artifacts.
10
+ - Preserve the evidence-first output model.
11
+
12
+ ## Available upgrades
13
+
14
+ ### 1) Tuned lexical baseline
15
+
16
+ - BM25-style scoring with configurable parameters.
17
+ - N-gram range controls.
18
+ - Stop word strategy per backend.
19
+ - Field weighting (for example: title, body, metadata).
20
+
21
+ ### 2) Reranking stage
22
+
23
+ - Optional rerank step that re-scores top-N candidates.
24
+ - Deterministic scoring keeps rerank behavior reproducible.
25
+
26
+ ### 3) Hybrid retrieval
27
+
28
+ - Combine lexical and embedding signals.
29
+ - Expose fusion weights in the recipe schema.
30
+ - Emit stage-level scores and weights in evidence metadata.
31
+
32
+ ## Evaluation guidance
33
+
34
+ - Measure accuracy-at-k and compare against the same datasets.
35
+ - Run artifacts capture each stage and configuration for auditability.
36
+ - Deterministic settings remain available as the default baseline.
37
+
38
+ ## Non-goals
39
+
40
+ - Automated hyperparameter tuning.
41
+ - Hidden fallback stages that obscure retrieval behavior.
42
+ - UI-driven tuning in this phase.
@@ -17,34 +17,27 @@ If you are looking for what already exists, start with:
17
17
  - Raw corpus items remain readable, portable files.
18
18
  - Derived artifacts are stored under the corpus and can coexist for multiple implementations.
19
19
 
20
- ## Next: retrieval evaluation and datasets
20
+ ## Completed foundations
21
21
 
22
- Goal: make evaluation results easier to interpret and compare.
22
+ These are the capability slices that already exist and have end-to-end behavior specifications.
23
23
 
24
- Deliverables:
25
-
26
- - A dataset authoring workflow that supports small hand-labeled sets and larger synthetic sets.
27
- - A report that includes per-query diagnostics and a clear summary.
28
-
29
- Acceptance checks:
24
+ ### Retrieval evaluation and datasets
30
25
 
31
- - Dataset formats are versioned when they change.
32
- - Reports remain deterministic for the same inputs.
26
+ - Dataset authoring workflow for small hand-labeled sets and larger synthetic sets.
27
+ - Evaluation reports with per-query diagnostics and summary metrics.
28
+ - Versioned dataset formats and deterministic reports for stable inputs.
33
29
 
34
- ## Next: context pack policy surfaces
30
+ ### Retrieval quality upgrades
35
31
 
36
- Goal: make context shaping policies easier to evaluate and swap.
32
+ - Tuned lexical baseline with BM25, n-gram range controls, and stop word policies.
33
+ - Reranking stage for top-N candidates with explicit stage metadata.
34
+ - Hybrid retrieval with explicit fusion weights and stage-level scores.
37
35
 
38
- Deliverables:
39
-
40
- - A clear set of context pack policy variants (formatting, ordering, metadata inclusion).
41
- - Token budget strategies that can use a real tokenizer.
42
- - Documentation that explains where context shaping fits in the pipeline.
43
-
44
- Acceptance checks:
36
+ ### Context pack policy surfaces
45
37
 
46
- - Behavior specifications cover policy selection and budgeting behaviors.
47
- - Example outputs show how context packs differ across policies.
38
+ - Policy variants for formatting, ordering, and metadata inclusion.
39
+ - Token and character budget strategies with explicit selectors.
40
+ - Documentation and examples that show how policy choices change outputs.
48
41
 
49
42
  ## Next: extraction evaluation harness
50
43
 
@@ -67,7 +60,7 @@ Goal: provide lightweight analysis utilities that summarize corpus themes and gu
67
60
 
68
61
  Deliverables:
69
62
 
70
- - Basic data profiling reports (counts, media types, size distributions, tag coverage).
63
+ - Basic corpus profiling with deterministic metrics for raw items and extracted text.
71
64
  - Hidden Markov modeling analysis for sequence-driven corpora.
72
65
  - A way to compare analysis outputs across corpora or corpus snapshots.
73
66
 
@@ -120,12 +120,12 @@ title: My Document
120
120
  tags: [note, draft]
121
121
  ---
122
122
 
123
- This is the body content that will be extracted.
123
+ This is the body content that is extracted.
124
124
  ```
125
125
 
126
126
  Output text:
127
127
  ```
128
- This is the body content that will be extracted.
128
+ This is the body content that is extracted.
129
129
  ```
130
130
 
131
131
  ### Mixed Format Pipeline
@@ -185,7 +185,7 @@ Non-text items are silently skipped (returns `None`). This allows the extractor
185
185
 
186
186
  ### Encoding Errors
187
187
 
188
- UTF-8 decoding errors will cause per-item failures recorded in `errored_items` but won't halt the entire extraction run.
188
+ UTF-8 decoding errors cause per-item failures recorded in `errored_items` but do not halt the entire extraction run.
189
189
 
190
190
  ### Missing Files
191
191
 
@@ -78,7 +78,7 @@ class UnstructuredExtractorConfig(BaseModel):
78
78
 
79
79
  ### Configuration Options
80
80
 
81
- This extractor currently accepts no configuration. Future versions may expose Unstructured library options.
81
+ This extractor currently accepts no configuration. Optional extensions may expose Unstructured library options.
82
82
 
83
83
  ## Usage
84
84
 
@@ -15,6 +15,9 @@ Contents
15
15
  KNOWLEDGE_BASE
16
16
  BACKENDS
17
17
  backends/index
18
+ RETRIEVAL
19
+ RETRIEVAL_QUALITY
20
+ RETRIEVAL_EVALUATION
18
21
  CONTEXT_PACK
19
22
  ANALYSIS
20
23
  PROFILING
@@ -23,6 +23,31 @@ Feature: Context pack command-line interface
23
23
  one two three
24
24
  """
25
25
 
26
+ Scenario: Context pack build can include metadata
27
+ Given a retrieval result exists with sourced evidence:
28
+ | source_uri | score | text |
29
+ | source-a | 10.0 | alpha |
30
+ When I run "context-pack build" joining with "\n\n" ordering "score" and including metadata
31
+ Then the context pack build output text equals:
32
+ """
33
+ item_id: item-1
34
+ source_uri: source-a
35
+ score: 10.0
36
+ stage: scan
37
+ alpha
38
+ """
39
+
40
+ Scenario: Context pack build can fit to a character budget
41
+ Given a retrieval result exists with evidence text:
42
+ | text |
43
+ | alpha |
44
+ | beta |
45
+ When I run "context-pack build" joining with "\n\n" and character budget 6
46
+ Then the context pack build output text equals:
47
+ """
48
+ alpha
49
+ """
50
+
26
51
  Scenario: Context pack build fails without retrieval result on standard input
27
52
  When I run "context-pack build" with empty standard input
28
53
  Then the command fails with exit code 2
@@ -0,0 +1,92 @@
1
+ Feature: Context pack policies
2
+ Context pack policies control evidence ordering, metadata inclusion, and budgets.
3
+
4
+ Scenario: Score ordering sorts evidence by score
5
+ Given a retrieval result exists with scored evidence:
6
+ | score | text |
7
+ | 1.0 | beta |
8
+ | 5.0 | alpha |
9
+ When I build a context pack from that retrieval result with policy:
10
+ | key | value |
11
+ | join_with | \n\n |
12
+ | ordering | score |
13
+ | include_metadata | false |
14
+ Then the context pack text equals:
15
+ """
16
+ alpha
17
+
18
+ beta
19
+ """
20
+
21
+ Scenario: Source ordering groups evidence by source
22
+ Given a retrieval result exists with sourced evidence:
23
+ | source_uri | score | text |
24
+ | source-b | 1.0 | beta |
25
+ | source-a | 2.0 | alpha |
26
+ | source-a | 1.0 | delta |
27
+ When I build a context pack from that retrieval result with policy:
28
+ | key | value |
29
+ | join_with | \n\n |
30
+ | ordering | source |
31
+ | include_metadata | false |
32
+ Then the context pack text equals:
33
+ """
34
+ alpha
35
+
36
+ delta
37
+
38
+ beta
39
+ """
40
+
41
+ Scenario: Metadata inclusion prepends block metadata
42
+ Given a retrieval result exists with sourced evidence:
43
+ | source_uri | score | text |
44
+ | source-a | 10.0 | alpha |
45
+ When I build a context pack from that retrieval result with policy:
46
+ | key | value |
47
+ | join_with | \n\n |
48
+ | ordering | rank |
49
+ | include_metadata | true |
50
+ Then the context pack text equals:
51
+ """
52
+ item_id: item-1
53
+ source_uri: source-a
54
+ score: 10.0
55
+ stage: scan
56
+ alpha
57
+ """
58
+
59
+ Scenario: Character budgets drop trailing blocks
60
+ Given a retrieval result exists with evidence text:
61
+ | text |
62
+ | alpha |
63
+ | beta |
64
+ When I build a context pack from that retrieval result with policy:
65
+ | key | value |
66
+ | join_with | \n\n |
67
+ | ordering | rank |
68
+ | include_metadata | false |
69
+ And I fit the context pack to a character budget of 6 characters
70
+ Then the context pack text equals:
71
+ """
72
+ alpha
73
+ """
74
+
75
+ Scenario: Character budgets can produce empty context packs
76
+ Given a retrieval result exists with evidence text:
77
+ | text |
78
+ | alpha |
79
+ When I build a context pack from that retrieval result with policy:
80
+ | key | value |
81
+ | join_with | \n\n |
82
+ | ordering | rank |
83
+ | include_metadata | false |
84
+ And I fit the context pack to a character budget of 1 characters
85
+ Then the context pack text is empty
86
+
87
+ Scenario: Unknown ordering raises a policy error
88
+ Given a retrieval result exists with evidence text:
89
+ | text |
90
+ | alpha |
91
+ When I attempt to build a context pack with invalid ordering "mystery"
92
+ Then the context pack ordering error mentions "Unknown context pack ordering"