briefloop 0.11.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (424) hide show
  1. briefloop-0.11.12.dist-info/METADATA +473 -0
  2. briefloop-0.11.12.dist-info/RECORD +424 -0
  3. briefloop-0.11.12.dist-info/WHEEL +5 -0
  4. briefloop-0.11.12.dist-info/entry_points.txt +3 -0
  5. briefloop-0.11.12.dist-info/licenses/LICENSE +22 -0
  6. briefloop-0.11.12.dist-info/top_level.txt +1 -0
  7. multi_agent_brief/__init__.py +36 -0
  8. multi_agent_brief/analysis_blocks/__init__.py +11 -0
  9. multi_agent_brief/analysis_blocks/builder.py +206 -0
  10. multi_agent_brief/analysis_blocks/renderer.py +237 -0
  11. multi_agent_brief/analysis_blocks/schemas.py +52 -0
  12. multi_agent_brief/analysis_modules/__init__.py +8 -0
  13. multi_agent_brief/analysis_modules/base.py +87 -0
  14. multi_agent_brief/analysis_modules/market_competitor/__init__.py +68 -0
  15. multi_agent_brief/analysis_modules/market_competitor/auditor.py +290 -0
  16. multi_agent_brief/analysis_modules/market_competitor/config.py +187 -0
  17. multi_agent_brief/analysis_modules/market_competitor/event_builder.py +226 -0
  18. multi_agent_brief/analysis_modules/market_competitor/renderer.py +199 -0
  19. multi_agent_brief/analysis_modules/market_competitor/schemas.py +518 -0
  20. multi_agent_brief/analysis_modules/policy_regulatory/__init__.py +7 -0
  21. multi_agent_brief/analysis_modules/policy_regulatory/audit.py +195 -0
  22. multi_agent_brief/analysis_modules/policy_regulatory/module.py +387 -0
  23. multi_agent_brief/analysis_modules/policy_regulatory/schemas.py +129 -0
  24. multi_agent_brief/analysis_modules/registry.py +73 -0
  25. multi_agent_brief/audience/__init__.py +19 -0
  26. multi_agent_brief/audience/profiles.py +246 -0
  27. multi_agent_brief/audience_memory/__init__.py +23 -0
  28. multi_agent_brief/audience_memory/profile.py +358 -0
  29. multi_agent_brief/audit/__init__.py +36 -0
  30. multi_agent_brief/audit/case_applicability.py +181 -0
  31. multi_agent_brief/audit/deterministic.py +471 -0
  32. multi_agent_brief/audit/editorial_governance.py +404 -0
  33. multi_agent_brief/audit/final_quality.py +764 -0
  34. multi_agent_brief/audit/harness.py +242 -0
  35. multi_agent_brief/audit/interfaces.py +96 -0
  36. multi_agent_brief/audit/limitation_hygiene.py +238 -0
  37. multi_agent_brief/audit/proposal_boundary.py +34 -0
  38. multi_agent_brief/audit/redaction.py +27 -0
  39. multi_agent_brief/audit/rule_packs.py +96 -0
  40. multi_agent_brief/audit/semantic.py +435 -0
  41. multi_agent_brief/capabilities/__init__.py +22 -0
  42. multi_agent_brief/capabilities/catalog.py +215 -0
  43. multi_agent_brief/capabilities/detect.py +199 -0
  44. multi_agent_brief/capabilities/models.py +60 -0
  45. multi_agent_brief/capabilities/recommend.py +206 -0
  46. multi_agent_brief/cli/__init__.py +2 -0
  47. multi_agent_brief/cli/analysis_commands.py +140 -0
  48. multi_agent_brief/cli/approval_commands.py +107 -0
  49. multi_agent_brief/cli/audit_commands.py +59 -0
  50. multi_agent_brief/cli/capability_commands.py +548 -0
  51. multi_agent_brief/cli/claude_commands.py +159 -0
  52. multi_agent_brief/cli/competitors_commands.py +182 -0
  53. multi_agent_brief/cli/controls_commands.py +137 -0
  54. multi_agent_brief/cli/deliver_commands.py +942 -0
  55. multi_agent_brief/cli/eval_cases_commands.py +99 -0
  56. multi_agent_brief/cli/experiments_commands.py +395 -0
  57. multi_agent_brief/cli/feedback_commands.py +192 -0
  58. multi_agent_brief/cli/finalize_commands.py +153 -0
  59. multi_agent_brief/cli/gates_commands.py +174 -0
  60. multi_agent_brief/cli/hermes_commands.py +356 -0
  61. multi_agent_brief/cli/improve_commands.py +224 -0
  62. multi_agent_brief/cli/init_commands.py +564 -0
  63. multi_agent_brief/cli/init_wizard.py +1473 -0
  64. multi_agent_brief/cli/input_commands.py +237 -0
  65. multi_agent_brief/cli/main.py +288 -0
  66. multi_agent_brief/cli/onboard_commands.py +193 -0
  67. multi_agent_brief/cli/product_commands.py +1449 -0
  68. multi_agent_brief/cli/provenance_commands.py +100 -0
  69. multi_agent_brief/cli/release_commands.py +68 -0
  70. multi_agent_brief/cli/repair_commands.py +169 -0
  71. multi_agent_brief/cli/run_commands.py +292 -0
  72. multi_agent_brief/cli/runtime_commands.py +81 -0
  73. multi_agent_brief/cli/secrets_commands.py +232 -0
  74. multi_agent_brief/cli/semantic_support_commands.py +80 -0
  75. multi_agent_brief/cli/sources_commands.py +647 -0
  76. multi_agent_brief/cli/start_commands.py +8 -0
  77. multi_agent_brief/cli/state_commands.py +446 -0
  78. multi_agent_brief/cli/status_commands.py +26 -0
  79. multi_agent_brief/cli/workbuddy_commands.py +103 -0
  80. multi_agent_brief/configs/artifact_contracts.yaml +514 -0
  81. multi_agent_brief/configs/orchestrator_contract.yaml +181 -0
  82. multi_agent_brief/configs/policy_packs/default.yaml +65 -0
  83. multi_agent_brief/configs/policy_profiles/evidence_extract_default.yaml +58 -0
  84. multi_agent_brief/configs/policy_profiles/finance_default.yaml +44 -0
  85. multi_agent_brief/configs/policy_profiles/internet_default.yaml +44 -0
  86. multi_agent_brief/configs/policy_profiles/manufacturing_default.yaml +33 -0
  87. multi_agent_brief/configs/policy_profiles/solar_manufacturing_default.yaml +64 -0
  88. multi_agent_brief/configs/report_packs/evidence_extract.yaml +48 -0
  89. multi_agent_brief/configs/report_packs/management_monthly.yaml +36 -0
  90. multi_agent_brief/configs/report_packs/market_weekly.yaml +36 -0
  91. multi_agent_brief/configs/report_packs/solar_industry_periodic.yaml +50 -0
  92. multi_agent_brief/configs/report_templates/evidence_extract.yaml +55 -0
  93. multi_agent_brief/configs/report_templates/management_monthly.yaml +48 -0
  94. multi_agent_brief/configs/report_templates/market_weekly.yaml +49 -0
  95. multi_agent_brief/configs/report_templates/solar_industry_periodic.yaml +75 -0
  96. multi_agent_brief/configs/stage_specs.yaml +180 -0
  97. multi_agent_brief/contracts/__init__.py +41 -0
  98. multi_agent_brief/contracts/base.py +99 -0
  99. multi_agent_brief/contracts/errors.py +41 -0
  100. multi_agent_brief/contracts/migrations/__init__.py +5 -0
  101. multi_agent_brief/contracts/migrations/claim_v1_to_v2.py +33 -0
  102. multi_agent_brief/contracts/registry.py +159 -0
  103. multi_agent_brief/contracts/role_topology.py +25 -0
  104. multi_agent_brief/contracts/schemas/__init__.py +35 -0
  105. multi_agent_brief/contracts/schemas/analysis_pack.py +135 -0
  106. multi_agent_brief/contracts/schemas/atomic_claim_graph.py +304 -0
  107. multi_agent_brief/contracts/schemas/audit_report.py +80 -0
  108. multi_agent_brief/contracts/schemas/candidate_item.py +51 -0
  109. multi_agent_brief/contracts/schemas/claim.py +197 -0
  110. multi_agent_brief/contracts/schemas/claim_draft.py +386 -0
  111. multi_agent_brief/contracts/schemas/claim_support_matrix.py +334 -0
  112. multi_agent_brief/contracts/schemas/evidence_span_registry.py +270 -0
  113. multi_agent_brief/contracts/schemas/policy_profile.py +247 -0
  114. multi_agent_brief/contracts/schemas/report_spec.py +257 -0
  115. multi_agent_brief/contracts/schemas/semantic_assessment_report.py +480 -0
  116. multi_agent_brief/contracts/schemas/source_evidence_pack_manifest.py +233 -0
  117. multi_agent_brief/contracts/schemas/source_item.py +96 -0
  118. multi_agent_brief/contracts/semantic_assessment_status.py +12 -0
  119. multi_agent_brief/contracts/source_metadata.py +252 -0
  120. multi_agent_brief/contracts/target_contract.py +460 -0
  121. multi_agent_brief/contracts/validator.py +225 -0
  122. multi_agent_brief/controls/__init__.py +23 -0
  123. multi_agent_brief/controls/contract.py +106 -0
  124. multi_agent_brief/controls/switchboard.py +1076 -0
  125. multi_agent_brief/core/__init__.py +2 -0
  126. multi_agent_brief/core/citations.py +14 -0
  127. multi_agent_brief/core/claim_ledger.py +94 -0
  128. multi_agent_brief/core/config.py +191 -0
  129. multi_agent_brief/core/env.py +69 -0
  130. multi_agent_brief/core/previous.py +83 -0
  131. multi_agent_brief/core/schemas.py +181 -0
  132. multi_agent_brief/core/selection.py +189 -0
  133. multi_agent_brief/delivery/__init__.py +6 -0
  134. multi_agent_brief/delivery/base.py +36 -0
  135. multi_agent_brief/delivery/feishu.py +204 -0
  136. multi_agent_brief/delivery/gws.py +237 -0
  137. multi_agent_brief/evaluation_cases/__init__.py +15 -0
  138. multi_agent_brief/evaluation_cases/contract.py +429 -0
  139. multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/config.yaml +18 -0
  140. multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/improvement/ledger.jsonl +2 -0
  141. multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/sources.yaml +2 -0
  142. multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/user.md +4 -0
  143. multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/config.yaml +13 -0
  144. multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/sources.yaml +9 -0
  145. multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/user.md +4 -0
  146. multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/config.yaml +12 -0
  147. multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/sources.yaml +6 -0
  148. multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/user.md +4 -0
  149. multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/config.yaml +6 -0
  150. multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/input/human_feedback.md +1 -0
  151. multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/sources.yaml +2 -0
  152. multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/user.md +3 -0
  153. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/config.yaml +8 -0
  154. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/brief.md +14 -0
  155. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/audit_report.json +1 -0
  156. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/audited_brief.md +5 -0
  157. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/candidate_claims.json +1 -0
  158. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/claim_ledger.json +1 -0
  159. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/screened_candidates.json +1 -0
  160. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/sources.yaml +2 -0
  161. multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/user.md +3 -0
  162. multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/config.yaml +13 -0
  163. multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/sources.yaml +9 -0
  164. multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/user.md +4 -0
  165. multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/config.yaml +4 -0
  166. multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/sources.yaml +2 -0
  167. multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/user.md +3 -0
  168. multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/config.yaml +13 -0
  169. multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/sources.yaml +9 -0
  170. multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/user.md +4 -0
  171. multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/config.yaml +13 -0
  172. multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/sources.yaml +9 -0
  173. multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/user.md +5 -0
  174. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/config.yaml +6 -0
  175. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/audited_brief.md +3 -0
  176. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/candidate_claims.json +1 -0
  177. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/claim_ledger.json +1 -0
  178. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/feedback_issues.json +25 -0
  179. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/repair_plan.json +27 -0
  180. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/screened_candidates.json +1 -0
  181. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/sources.yaml +2 -0
  182. multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/user.md +3 -0
  183. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/config.yaml +8 -0
  184. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/audit_report.json +1 -0
  185. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/audited_brief.md +3 -0
  186. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/candidate_claims.json +1 -0
  187. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/claim_ledger.json +11 -0
  188. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/quality_gate_report.json +22 -0
  189. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/screened_candidates.json +1 -0
  190. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/sources.yaml +2 -0
  191. multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/user.md +3 -0
  192. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/config.yaml +13 -0
  193. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/audit_report.json +1 -0
  194. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/audited_brief.md +5 -0
  195. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/candidate_claims.json +1 -0
  196. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/claim_ledger.json +40 -0
  197. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/screened_candidates.json +1 -0
  198. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/sources.yaml +3 -0
  199. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/user.md +3 -0
  200. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/config.yaml +8 -0
  201. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/brief.md +3 -0
  202. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/audit_report.json +1 -0
  203. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/audited_brief.md +3 -0
  204. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/candidate_claims.json +1 -0
  205. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/claim_ledger.json +13 -0
  206. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/screened_candidates.json +1 -0
  207. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/sources.yaml +2 -0
  208. multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/user.md +3 -0
  209. multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/config.yaml +13 -0
  210. multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/output/intermediate/release_readiness_report.json +31 -0
  211. multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/sources.yaml +9 -0
  212. multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/user.md +4 -0
  213. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/config.yaml +18 -0
  214. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/improvement/ledger.jsonl +3 -0
  215. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/improvement/memory.md +3 -0
  216. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/output/intermediate/improvement_memory_snapshot.md +3 -0
  217. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/sources.yaml +2 -0
  218. multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/user.md +4 -0
  219. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/config.yaml +12 -0
  220. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/input/sources/source-001.txt +1 -0
  221. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/brief.md +37 -0
  222. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/delivery/brief.md +37 -0
  223. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/atomic_claim_graph.json +17 -0
  224. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/audit_report.json +5 -0
  225. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/audited_brief.md +37 -0
  226. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/claim_ledger.json +20 -0
  227. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/evidence_span_registry.json +20 -0
  228. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/finalize_report.json +40 -0
  229. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/gates/auditor_quality_gate_report.json +42 -0
  230. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/gates/finalize_quality_gate_report.json +42 -0
  231. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/screened_candidates.json +33 -0
  232. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/source_appendix.md +12 -0
  233. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/source_appendix_trace.md +10 -0
  234. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/report_spec.yaml +24 -0
  235. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/sources.yaml +4 -0
  236. multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/user.md +3 -0
  237. multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/config.yaml +13 -0
  238. multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/input/sources/README.md +4 -0
  239. multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/output/intermediate/source_evidence_pack_manifest.json +26 -0
  240. multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/sources.yaml +9 -0
  241. multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/user.md +4 -0
  242. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/config.yaml +9 -0
  243. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/audit_report.json +1 -0
  244. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/audited_brief.md +3 -0
  245. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/candidate_claims.json +1 -0
  246. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/claim_ledger.json +13 -0
  247. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/screened_candidates.json +1 -0
  248. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/sources.yaml +2 -0
  249. multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/user.md +3 -0
  250. multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/config.yaml +13 -0
  251. multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/sources.yaml +9 -0
  252. multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/user.md +4 -0
  253. multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/config.yaml +4 -0
  254. multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/sources.yaml +2 -0
  255. multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/user.md +3 -0
  256. multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/config.yaml +18 -0
  257. multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/improvement/ledger.jsonl +1 -0
  258. multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/sources.yaml +2 -0
  259. multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/user.md +4 -0
  260. multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/config.yaml +18 -0
  261. multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/sources.yaml +9 -0
  262. multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/user.md +5 -0
  263. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/config.yaml +8 -0
  264. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/audit_report.json +1 -0
  265. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/audited_brief.md +8 -0
  266. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/candidate_claims.json +1 -0
  267. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/claim_ledger.json +1 -0
  268. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/screened_candidates.json +1 -0
  269. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/sources.yaml +2 -0
  270. multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/user.md +3 -0
  271. multi_agent_brief/evaluation_cases/fixtures/manifest.yaml +861 -0
  272. multi_agent_brief/evaluation_cases/fixtures.py +20 -0
  273. multi_agent_brief/evaluation_cases/runner.py +1603 -0
  274. multi_agent_brief/experiments/__init__.py +45 -0
  275. multi_agent_brief/experiments/experiment_080.py +5835 -0
  276. multi_agent_brief/experiments/schemas.py +63 -0
  277. multi_agent_brief/experiments/target_contract.py +10 -0
  278. multi_agent_brief/feedback/__init__.py +17 -0
  279. multi_agent_brief/feedback/feedback_contract.py +482 -0
  280. multi_agent_brief/feedback/feedback_state.py +898 -0
  281. multi_agent_brief/hermes/__init__.py +25 -0
  282. multi_agent_brief/hermes/adapter.py +832 -0
  283. multi_agent_brief/improvement/__init__.py +83 -0
  284. multi_agent_brief/improvement/contract.py +1114 -0
  285. multi_agent_brief/improvement/memory.py +451 -0
  286. multi_agent_brief/improvement/product_definition.py +228 -0
  287. multi_agent_brief/improvement/state.py +961 -0
  288. multi_agent_brief/inputs/__init__.py +2 -0
  289. multi_agent_brief/inputs/classifier.py +322 -0
  290. multi_agent_brief/inputs/contracts.py +59 -0
  291. multi_agent_brief/inputs/extractor.py +310 -0
  292. multi_agent_brief/install/__init__.py +2 -0
  293. multi_agent_brief/install/writer.py +97 -0
  294. multi_agent_brief/onboarding/__init__.py +11 -0
  295. multi_agent_brief/onboarding/io.py +103 -0
  296. multi_agent_brief/onboarding/mapper.py +484 -0
  297. multi_agent_brief/onboarding/schema.py +46 -0
  298. multi_agent_brief/orchestrator/__init__.py +2 -0
  299. multi_agent_brief/orchestrator/fact_layer_import.py +352 -0
  300. multi_agent_brief/orchestrator/handoff.py +2209 -0
  301. multi_agent_brief/orchestrator/role_topology.py +42 -0
  302. multi_agent_brief/orchestrator/run_archive.py +888 -0
  303. multi_agent_brief/orchestrator/run_integrity.py +346 -0
  304. multi_agent_brief/orchestrator/runtime_state/__init__.py +70 -0
  305. multi_agent_brief/orchestrator/runtime_state/_io.py +167 -0
  306. multi_agent_brief/orchestrator/runtime_state/_transactions.py +298 -0
  307. multi_agent_brief/orchestrator/runtime_state/artifact_registry.py +1825 -0
  308. multi_agent_brief/orchestrator/runtime_state/atomic_claim_graph.py +96 -0
  309. multi_agent_brief/orchestrator/runtime_state/claim_ledger_freeze.py +510 -0
  310. multi_agent_brief/orchestrator/runtime_state/claim_metadata_enrichment.py +836 -0
  311. multi_agent_brief/orchestrator/runtime_state/claim_support_matrix.py +582 -0
  312. multi_agent_brief/orchestrator/runtime_state/completion_gates.py +672 -0
  313. multi_agent_brief/orchestrator/runtime_state/contracts_loader.py +66 -0
  314. multi_agent_brief/orchestrator/runtime_state/decisions.py +239 -0
  315. multi_agent_brief/orchestrator/runtime_state/errors.py +61 -0
  316. multi_agent_brief/orchestrator/runtime_state/event_log.py +256 -0
  317. multi_agent_brief/orchestrator/runtime_state/evidence_span_registry.py +233 -0
  318. multi_agent_brief/orchestrator/runtime_state/fact_layer.py +755 -0
  319. multi_agent_brief/orchestrator/runtime_state/identity.py +90 -0
  320. multi_agent_brief/orchestrator/runtime_state/lifecycle.py +675 -0
  321. multi_agent_brief/orchestrator/runtime_state/manifest.py +82 -0
  322. multi_agent_brief/orchestrator/runtime_state/operations.py +224 -0
  323. multi_agent_brief/orchestrator/runtime_state/paths.py +38 -0
  324. multi_agent_brief/orchestrator/runtime_state/repair.py +984 -0
  325. multi_agent_brief/orchestrator/runtime_state/safety_surfaces.py +147 -0
  326. multi_agent_brief/orchestrator/runtime_state/semantic_assessment_report.py +692 -0
  327. multi_agent_brief/orchestrator/runtime_state/semantic_support_acceptance.py +683 -0
  328. multi_agent_brief/orchestrator/runtime_state/source_evidence_pack.py +131 -0
  329. multi_agent_brief/orchestrator/runtime_state/stage_completion.py +1320 -0
  330. multi_agent_brief/orchestrator/runtime_state/trajectory.py +200 -0
  331. multi_agent_brief/orchestrator/runtime_state/workflow.py +350 -0
  332. multi_agent_brief/orchestrator/source_evidence.py +43 -0
  333. multi_agent_brief/orchestrator/timing.py +410 -0
  334. multi_agent_brief/orchestrator_contract.py +96 -0
  335. multi_agent_brief/outputs/__init__.py +2 -0
  336. multi_agent_brief/outputs/atomic_reader_projection.py +288 -0
  337. multi_agent_brief/outputs/docx.py +32 -0
  338. multi_agent_brief/outputs/finalize.py +1036 -0
  339. multi_agent_brief/outputs/ib_docx.py +983 -0
  340. multi_agent_brief/outputs/naming.py +38 -0
  341. multi_agent_brief/outputs/pdf.py +20 -0
  342. multi_agent_brief/outputs/reader_final_gate.py +509 -0
  343. multi_agent_brief/outputs/reader_projection.py +397 -0
  344. multi_agent_brief/outputs/source_appendix.py +753 -0
  345. multi_agent_brief/outputs/templates/__init__.py +112 -0
  346. multi_agent_brief/product/__init__.py +49 -0
  347. multi_agent_brief/product/bundle_projection.py +686 -0
  348. multi_agent_brief/product/citation_profile.py +145 -0
  349. multi_agent_brief/product/guidance_manifestation.py +421 -0
  350. multi_agent_brief/product/materiality_selection.py +472 -0
  351. multi_agent_brief/product/policy_gate_adapter.py +116 -0
  352. multi_agent_brief/product/policy_profile.py +39 -0
  353. multi_agent_brief/product/policy_projection.py +161 -0
  354. multi_agent_brief/product/policy_registry.py +83 -0
  355. multi_agent_brief/product/policy_resolver.py +225 -0
  356. multi_agent_brief/product/quality_closeout.py +188 -0
  357. multi_agent_brief/product/quality_panel.py +2217 -0
  358. multi_agent_brief/product/release_approval.py +1034 -0
  359. multi_agent_brief/product/report_pack.py +130 -0
  360. multi_agent_brief/product/report_pack_aliases.py +68 -0
  361. multi_agent_brief/product/report_registry.py +101 -0
  362. multi_agent_brief/product/report_spec.py +181 -0
  363. multi_agent_brief/product/support_wording.py +525 -0
  364. multi_agent_brief/product/template_conformance.py +516 -0
  365. multi_agent_brief/product/template_projection.py +123 -0
  366. multi_agent_brief/product/template_registry.py +244 -0
  367. multi_agent_brief/product/template_render_plan.py +315 -0
  368. multi_agent_brief/product/template_renderer.py +224 -0
  369. multi_agent_brief/product/trajectory_regulation.py +441 -0
  370. multi_agent_brief/provenance/__init__.py +5 -0
  371. multi_agent_brief/provenance/builder.py +841 -0
  372. multi_agent_brief/provenance/contract.py +21 -0
  373. multi_agent_brief/provenance/io.py +144 -0
  374. multi_agent_brief/provenance/model.py +110 -0
  375. multi_agent_brief/provenance/references.py +43 -0
  376. multi_agent_brief/provenance/validator.py +135 -0
  377. multi_agent_brief/quality_gates/__init__.py +19 -0
  378. multi_agent_brief/quality_gates/contract.py +581 -0
  379. multi_agent_brief/quality_gates/state.py +2498 -0
  380. multi_agent_brief/repair/__init__.py +5 -0
  381. multi_agent_brief/repair/router.py +842 -0
  382. multi_agent_brief/runtime_assets.py +431 -0
  383. multi_agent_brief/sources/__init__.py +16 -0
  384. multi_agent_brief/sources/api_filings.py +236 -0
  385. multi_agent_brief/sources/api_news.py +174 -0
  386. multi_agent_brief/sources/base.py +142 -0
  387. multi_agent_brief/sources/cached_package.py +119 -0
  388. multi_agent_brief/sources/cli_provider.py +263 -0
  389. multi_agent_brief/sources/coverage.py +336 -0
  390. multi_agent_brief/sources/decider.py +756 -0
  391. multi_agent_brief/sources/doctor.py +373 -0
  392. multi_agent_brief/sources/evidence_pack.py +364 -0
  393. multi_agent_brief/sources/feishu_provider.py +326 -0
  394. multi_agent_brief/sources/filing_resolver.py +400 -0
  395. multi_agent_brief/sources/industry_packs.py +130 -0
  396. multi_agent_brief/sources/join.py +206 -0
  397. multi_agent_brief/sources/local_signal.py +81 -0
  398. multi_agent_brief/sources/local_signal_planner.py +636 -0
  399. multi_agent_brief/sources/manual.py +259 -0
  400. multi_agent_brief/sources/mcp_provider.py +309 -0
  401. multi_agent_brief/sources/mineru_provider.py +601 -0
  402. multi_agent_brief/sources/normalizer.py +95 -0
  403. multi_agent_brief/sources/opencli_provider.py +282 -0
  404. multi_agent_brief/sources/planner.py +178 -0
  405. multi_agent_brief/sources/registry.py +367 -0
  406. multi_agent_brief/sources/rss.py +190 -0
  407. multi_agent_brief/sources/search_backends/__init__.py +31 -0
  408. multi_agent_brief/sources/search_backends/base.py +51 -0
  409. multi_agent_brief/sources/search_backends/brave.py +192 -0
  410. multi_agent_brief/sources/search_backends/capabilities.py +94 -0
  411. multi_agent_brief/sources/search_backends/exa.py +180 -0
  412. multi_agent_brief/sources/search_backends/firecrawl.py +164 -0
  413. multi_agent_brief/sources/search_backends/serper.py +241 -0
  414. multi_agent_brief/sources/search_backends/tavily.py +124 -0
  415. multi_agent_brief/sources/sourcehub.py +505 -0
  416. multi_agent_brief/sources/web_search.py +267 -0
  417. multi_agent_brief/status.py +966 -0
  418. multi_agent_brief/tools/__init__.py +3 -0
  419. multi_agent_brief/tools/draft_cleanup.py +198 -0
  420. multi_agent_brief/workbuddy/__init__.py +1 -0
  421. multi_agent_brief/workbuddy/diagnose.py +569 -0
  422. multi_agent_brief/workbuddy/skill_pack.py +309 -0
  423. multi_agent_brief/workspace/__init__.py +1 -0
  424. multi_agent_brief/workspace/init_profile.py +45 -0
@@ -0,0 +1,233 @@
1
+ """Contract for durable source evidence pack manifests."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import Any, ClassVar
7
+
8
+ from multi_agent_brief.contracts.base import Contract, SchemaRegistry
9
+ from multi_agent_brief.contracts.errors import FieldViolation
10
+ from multi_agent_brief.contracts.source_metadata import (
11
+ VALID_RETRIEVAL_SOURCE_TYPES,
12
+ VALID_SOURCE_CATEGORIES,
13
+ VALID_UNDERLYING_EVIDENCE_TYPES,
14
+ retrieval_source_type_error,
15
+ source_category_error,
16
+ underlying_evidence_type_error,
17
+ )
18
+
19
+ SOURCE_EVIDENCE_PACK_MANIFEST_SCHEMA_VERSION = "mabw.source_evidence_pack_manifest.v1"
20
+ SHA256_RE = re.compile(r"^[0-9a-f]{64}$")
21
+
22
+
23
+ @SchemaRegistry.register
24
+ class SourceEvidencePackManifestContract(Contract):
25
+ """Validate source evidence pack manifest shape.
26
+
27
+ This contract validates deterministic source-pack bookkeeping only. It does
28
+ not judge whether a source supports a claim.
29
+ """
30
+
31
+ schema_id: ClassVar[str] = "source_evidence_pack_manifest"
32
+ schema_version: ClassVar[str] = "v1"
33
+
34
+ @classmethod
35
+ def json_schema(cls) -> dict[str, Any]:
36
+ return {
37
+ "type": "object",
38
+ "required": ["schema_version", "records", "pack_sha256"],
39
+ "properties": {
40
+ "schema_version": {
41
+ "type": "string",
42
+ "enum": [SOURCE_EVIDENCE_PACK_MANIFEST_SCHEMA_VERSION],
43
+ },
44
+ "source": {"type": "string"},
45
+ "source_config_path": {"type": "string"},
46
+ "record_count": {"type": "integer", "minimum": 1},
47
+ "error_count": {"type": "integer", "minimum": 0},
48
+ "pack_sha256": {"type": "string", "pattern": SHA256_RE.pattern},
49
+ "durable_provider_names": {
50
+ "type": "array",
51
+ "items": {"type": "string"},
52
+ },
53
+ "records": {
54
+ "type": "array",
55
+ "minItems": 1,
56
+ "items": {
57
+ "type": "object",
58
+ "required": ["source_id", "path", "sha256", "size_bytes"],
59
+ "properties": {
60
+ "source_id": {"type": "string"},
61
+ "path": {"type": "string"},
62
+ "sha256": {"type": "string", "pattern": SHA256_RE.pattern},
63
+ "size_bytes": {"type": "integer", "minimum": 1},
64
+ "source_url": {"type": "string"},
65
+ "source_title": {"type": "string"},
66
+ "publisher": {"type": "string"},
67
+ "source_type": {"type": "string"},
68
+ "source_category": {
69
+ "type": "string",
70
+ "enum": sorted(VALID_SOURCE_CATEGORIES),
71
+ },
72
+ "retrieval_source_type": {
73
+ "type": "string",
74
+ "enum": sorted(VALID_RETRIEVAL_SOURCE_TYPES),
75
+ },
76
+ "underlying_evidence_type": {
77
+ "type": "string",
78
+ "enum": sorted(VALID_UNDERLYING_EVIDENCE_TYPES),
79
+ },
80
+ "raw_underlying_evidence_type": {"type": "string"},
81
+ },
82
+ "additionalProperties": True,
83
+ },
84
+ },
85
+ "provider_errors": {
86
+ "type": "array",
87
+ "items": {"type": "object"},
88
+ },
89
+ "non_goals": {
90
+ "type": "array",
91
+ "items": {"type": "string"},
92
+ },
93
+ },
94
+ "additionalProperties": True,
95
+ }
96
+
97
+ @classmethod
98
+ def validate(cls, data: dict[str, Any]) -> list[FieldViolation]:
99
+ if not isinstance(data, dict):
100
+ return [FieldViolation(field="<root>", error="must be an object")]
101
+
102
+ violations: list[FieldViolation] = []
103
+ schema_version = data.get("schema_version")
104
+ if not _non_empty_string(schema_version):
105
+ violations.append(FieldViolation(field="schema_version", error="required field is missing"))
106
+ elif schema_version != SOURCE_EVIDENCE_PACK_MANIFEST_SCHEMA_VERSION:
107
+ violations.append(
108
+ FieldViolation(
109
+ field="schema_version",
110
+ error=f"must be {SOURCE_EVIDENCE_PACK_MANIFEST_SCHEMA_VERSION}",
111
+ )
112
+ )
113
+
114
+ records = data.get("records")
115
+ if not isinstance(records, list) or not records:
116
+ violations.append(FieldViolation(field="records", error="must be a non-empty list"))
117
+ else:
118
+ seen_paths: set[str] = set()
119
+ seen_source_ids: set[str] = set()
120
+ for idx, record in enumerate(records):
121
+ violations.extend(
122
+ _validate_record(
123
+ record,
124
+ idx=idx,
125
+ seen_paths=seen_paths,
126
+ seen_source_ids=seen_source_ids,
127
+ )
128
+ )
129
+ record_count = data.get("record_count")
130
+ if record_count is not None and record_count != len(records):
131
+ violations.append(
132
+ FieldViolation(
133
+ field="record_count",
134
+ error=f"must equal records length:{len(records)}",
135
+ )
136
+ )
137
+
138
+ pack_sha = data.get("pack_sha256")
139
+ if not _valid_sha256(pack_sha):
140
+ violations.append(FieldViolation(field="pack_sha256", error="must be a lowercase sha256 hex digest"))
141
+
142
+ for field in ("record_count", "error_count"):
143
+ value = data.get(field)
144
+ if value is not None and (type(value) is not int or value < (1 if field == "record_count" else 0)):
145
+ violations.append(FieldViolation(field=field, error="must be a non-negative integer"))
146
+
147
+ provider_errors = data.get("provider_errors")
148
+ if provider_errors is not None and not isinstance(provider_errors, list):
149
+ violations.append(FieldViolation(field="provider_errors", error="must be a list"))
150
+ elif provider_errors is not None:
151
+ error_count = data.get("error_count")
152
+ if error_count is not None and error_count != len(provider_errors):
153
+ violations.append(
154
+ FieldViolation(
155
+ field="error_count",
156
+ error=f"must equal provider_errors length:{len(provider_errors)}",
157
+ )
158
+ )
159
+
160
+ return violations
161
+
162
+ @classmethod
163
+ def migrate(cls, data: dict[str, Any], from_version: str) -> dict[str, Any]:
164
+ return dict(data)
165
+
166
+
167
+ def _validate_record(
168
+ record: Any,
169
+ *,
170
+ idx: int,
171
+ seen_paths: set[str],
172
+ seen_source_ids: set[str],
173
+ ) -> list[FieldViolation]:
174
+ prefix = f"records[{idx}]"
175
+ if not isinstance(record, dict):
176
+ return [FieldViolation(field=prefix, error="must be an object")]
177
+
178
+ violations: list[FieldViolation] = []
179
+ source_id = record.get("source_id")
180
+ if not _non_empty_string(source_id):
181
+ violations.append(FieldViolation(field=f"{prefix}.source_id", error="must be a non-empty string"))
182
+ else:
183
+ normalized_source_id = str(source_id).strip()
184
+ if normalized_source_id in seen_source_ids:
185
+ violations.append(
186
+ FieldViolation(field=f"{prefix}.source_id", error=f"duplicate source_id:{normalized_source_id}")
187
+ )
188
+ seen_source_ids.add(normalized_source_id)
189
+
190
+ path = record.get("path")
191
+ if not _non_empty_string(path):
192
+ violations.append(FieldViolation(field=f"{prefix}.path", error="must be a non-empty string"))
193
+ else:
194
+ normalized_path = str(path).strip()
195
+ if normalized_path in seen_paths:
196
+ violations.append(FieldViolation(field=f"{prefix}.path", error=f"duplicate path:{normalized_path}"))
197
+ seen_paths.add(normalized_path)
198
+
199
+ if not _valid_sha256(record.get("sha256")):
200
+ violations.append(FieldViolation(field=f"{prefix}.sha256", error="must be a lowercase sha256 hex digest"))
201
+
202
+ size = record.get("size_bytes")
203
+ if type(size) is not int or size <= 0:
204
+ violations.append(FieldViolation(field=f"{prefix}.size_bytes", error="must be a positive integer"))
205
+
206
+ for field in (
207
+ "source_title",
208
+ "publisher",
209
+ "source_type",
210
+ "raw_underlying_evidence_type",
211
+ ):
212
+ value = record.get(field)
213
+ if value is not None and not _non_empty_string(value):
214
+ violations.append(FieldViolation(field=f"{prefix}.{field}", error="must be a non-empty string"))
215
+ category_error = source_category_error(record.get("source_category"))
216
+ if category_error:
217
+ violations.append(FieldViolation(field=f"{prefix}.source_category", error=category_error))
218
+ retrieval_error = retrieval_source_type_error(record.get("retrieval_source_type"))
219
+ if retrieval_error:
220
+ violations.append(FieldViolation(field=f"{prefix}.retrieval_source_type", error=retrieval_error))
221
+ underlying_error = underlying_evidence_type_error(record.get("underlying_evidence_type"))
222
+ if underlying_error:
223
+ violations.append(FieldViolation(field=f"{prefix}.underlying_evidence_type", error=underlying_error))
224
+
225
+ return violations
226
+
227
+
228
+ def _valid_sha256(value: Any) -> bool:
229
+ return isinstance(value, str) and bool(SHA256_RE.match(value.strip()))
230
+
231
+
232
+ def _non_empty_string(value: Any) -> bool:
233
+ return isinstance(value, str) and bool(value.strip())
@@ -0,0 +1,96 @@
1
+ """Contract for SourceItem."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, ClassVar
6
+
7
+ from multi_agent_brief.contracts.base import Contract, SchemaRegistry
8
+ from multi_agent_brief.contracts.errors import FieldViolation
9
+ from multi_agent_brief.contracts.source_metadata import (
10
+ VALID_RETRIEVAL_SOURCE_TYPES,
11
+ VALID_SOURCE_CATEGORIES,
12
+ VALID_UNDERLYING_EVIDENCE_TYPES,
13
+ retrieval_source_type_error,
14
+ source_category_error,
15
+ underlying_evidence_type_error,
16
+ )
17
+
18
+ REQUIRED_FIELDS = {"source_id", "source_name", "source_type", "title", "content"}
19
+ OPTIONAL_FIELDS = {
20
+ "url",
21
+ "published_at",
22
+ "retrieved_at",
23
+ "language",
24
+ "reliability",
25
+ "dedupe_key",
26
+ "source_category",
27
+ "retrieval_source_type",
28
+ "underlying_evidence_type",
29
+ "raw_underlying_evidence_type",
30
+ "metadata",
31
+ }
32
+ ALL_FIELDS = REQUIRED_FIELDS | OPTIONAL_FIELDS
33
+
34
+
35
+ @SchemaRegistry.register
36
+ class SourceItemContract(Contract):
37
+ schema_id: ClassVar[str] = "source_item"
38
+ schema_version: ClassVar[str] = "v1"
39
+
40
+ @classmethod
41
+ def json_schema(cls) -> dict[str, Any]:
42
+ return {
43
+ "type": "object",
44
+ "required": sorted(REQUIRED_FIELDS),
45
+ "properties": {
46
+ "source_id": {"type": "string"},
47
+ "source_name": {"type": "string"},
48
+ "source_type": {"type": "string"},
49
+ "title": {"type": "string"},
50
+ "content": {"type": "string"},
51
+ "url": {"type": "string"},
52
+ "published_at": {"type": "string"},
53
+ "retrieved_at": {"type": "string"},
54
+ "language": {"type": "string"},
55
+ "reliability": {"type": "string", "enum": ["low", "medium", "high"]},
56
+ "dedupe_key": {"type": "string"},
57
+ "source_category": {"type": "string", "enum": sorted(VALID_SOURCE_CATEGORIES)},
58
+ "retrieval_source_type": {
59
+ "type": "string",
60
+ "enum": sorted(VALID_RETRIEVAL_SOURCE_TYPES),
61
+ },
62
+ "underlying_evidence_type": {
63
+ "type": "string",
64
+ "enum": sorted(VALID_UNDERLYING_EVIDENCE_TYPES),
65
+ },
66
+ "raw_underlying_evidence_type": {"type": "string"},
67
+ "metadata": {"type": "object"},
68
+ },
69
+ "additionalProperties": True,
70
+ }
71
+
72
+ @classmethod
73
+ def validate(cls, data: dict[str, Any]) -> list[FieldViolation]:
74
+ violations: list[FieldViolation] = []
75
+ for field in REQUIRED_FIELDS:
76
+ val = data.get(field)
77
+ if val is None or (isinstance(val, str) and not val.strip()):
78
+ violations.append(FieldViolation(field=field, error="required field is missing or blank"))
79
+ category_error = source_category_error(data.get("source_category"))
80
+ if category_error:
81
+ violations.append(FieldViolation(field="source_category", error=category_error))
82
+ retrieval_error = retrieval_source_type_error(data.get("retrieval_source_type"))
83
+ if retrieval_error:
84
+ violations.append(FieldViolation(field="retrieval_source_type", error=retrieval_error))
85
+ underlying_error = underlying_evidence_type_error(data.get("underlying_evidence_type"))
86
+ if underlying_error:
87
+ violations.append(FieldViolation(field="underlying_evidence_type", error=underlying_error))
88
+ # Unknown fields as warnings
89
+ unknown = set(data.keys()) - ALL_FIELDS
90
+ for field in sorted(unknown):
91
+ violations.append(FieldViolation(field=field, error="unknown field", severity="warning"))
92
+ return violations
93
+
94
+ @classmethod
95
+ def migrate(cls, data: dict[str, Any], from_version: str) -> dict[str, Any]:
96
+ return dict(data) # no migration needed for v1
@@ -0,0 +1,12 @@
1
+ """Shared Semantic Assessment Report status vocabulary."""
2
+
3
+ from __future__ import annotations
4
+
5
+
6
+ SEMANTIC_ASSESSMENT_REPORT_STATUSES = (
7
+ "not_available",
8
+ "valid",
9
+ "stale",
10
+ "missing_input",
11
+ "invalid_report",
12
+ )
@@ -0,0 +1,252 @@
1
+ """Shared source metadata validation helpers."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import re
6
+ from typing import Any, Mapping
7
+ from urllib.parse import urlparse
8
+
9
+ SOURCE_CATEGORY_FIELD = "source_category"
10
+ VALID_SOURCE_CATEGORIES = {
11
+ "clin" + "ical_registry",
12
+ "company_press_release",
13
+ "industry_database",
14
+ "market_report",
15
+ "news_media",
16
+ "other",
17
+ "peer_reviewed_paper",
18
+ "preprint",
19
+ "regulator",
20
+ }
21
+ VALID_RETRIEVAL_SOURCE_TYPES = {
22
+ "blog",
23
+ "company_pr",
24
+ "dataset",
25
+ "filing",
26
+ "local_file",
27
+ "news_media",
28
+ "other",
29
+ "paper_page",
30
+ "podcast",
31
+ "social",
32
+ "video",
33
+ }
34
+ VALID_UNDERLYING_EVIDENCE_TYPES = {
35
+ "company_claim",
36
+ "conference_demo",
37
+ "filing",
38
+ "interview",
39
+ "market_data",
40
+ "media_report",
41
+ "peer_reviewed_paper",
42
+ "regulator_record",
43
+ "unknown",
44
+ }
45
+ SOURCE_CATEGORY_ALIASES = {
46
+ "company_claim": "company_press_release",
47
+ "company_official": "company_press_release",
48
+ "company_pr": "company_press_release",
49
+ "company_release": "company_press_release",
50
+ "company_source": "company_press_release",
51
+ "data_provider": "industry_database",
52
+ "government_regulator": "regulator",
53
+ "industry_media": "news_media",
54
+ "industry_news": "news_media",
55
+ "industry_report": "market_report",
56
+ "market_data": "industry_database",
57
+ "market_data_provider": "industry_database",
58
+ "media": "news_media",
59
+ "media_report": "news_media",
60
+ "news": "news_media",
61
+ "official_regulator": "regulator",
62
+ "paper": "peer_reviewed_paper",
63
+ "regulator_record": "regulator",
64
+ "regulatory": "regulator",
65
+ "research_institution": "market_report",
66
+ "research_report": "market_report",
67
+ "trade_publication": "news_media",
68
+ }
69
+ RETRIEVAL_SOURCE_TYPE_ALIASES = {
70
+ "academic_paper": "paper_page",
71
+ "article": "news_media",
72
+ "cached": "local_file",
73
+ "cached_package": "local_file",
74
+ "company_blog": "blog",
75
+ "company_official": "company_pr",
76
+ "company_release": "company_pr",
77
+ "company_source": "company_pr",
78
+ "government_regulator": "other",
79
+ "industry_media": "news_media",
80
+ "industry_news": "news_media",
81
+ "local": "local_file",
82
+ "manual": "local_file",
83
+ "manual_url": "other",
84
+ "market_data": "dataset",
85
+ "market_data_provider": "dataset",
86
+ "media": "news_media",
87
+ "news": "news_media",
88
+ "official_regulator": "other",
89
+ "paper": "paper_page",
90
+ "preprint": "paper_page",
91
+ "regulator_record": "other",
92
+ "regulatory": "other",
93
+ "research_report": "paper_page",
94
+ "sec_filing": "filing",
95
+ "trade_publication": "news_media",
96
+ }
97
+ UNDERLYING_EVIDENCE_TYPE_ALIASES = {
98
+ "academic_paper": "peer_reviewed_paper",
99
+ "company_press_release": "company_claim",
100
+ "company_official": "company_claim",
101
+ "company_pr": "company_claim",
102
+ "company_release": "company_claim",
103
+ "company_source": "company_claim",
104
+ "data_provider": "market_data",
105
+ "government_regulator": "regulator_record",
106
+ "industry_database": "market_data",
107
+ "industry_media": "media_report",
108
+ "industry_news": "media_report",
109
+ "market_data_provider": "market_data",
110
+ "market_report": "market_data",
111
+ "media": "media_report",
112
+ "news": "media_report",
113
+ "news_media": "media_report",
114
+ "official_regulator": "regulator_record",
115
+ "paper": "peer_reviewed_paper",
116
+ "press_release": "company_claim",
117
+ "regulator": "regulator_record",
118
+ "regulatory": "regulator_record",
119
+ "research_institution": "market_data",
120
+ "research_report": "media_report",
121
+ "sec_filing": "filing",
122
+ "trade_publication": "media_report",
123
+ }
124
+
125
+
126
+ def non_empty_text(value: Any) -> bool:
127
+ return isinstance(value, str) and bool(value.strip())
128
+
129
+
130
+ def source_url_error(value: Any) -> str | None:
131
+ if value is None or value == "":
132
+ return None
133
+ if not isinstance(value, str):
134
+ return "must be a string"
135
+ stripped = value.strip()
136
+ if not stripped:
137
+ return None
138
+ try:
139
+ parsed = urlparse(stripped)
140
+ except ValueError:
141
+ return "must be an http(s) URL"
142
+ if parsed.scheme not in {"http", "https"} or not parsed.netloc:
143
+ return "must be an http(s) URL"
144
+ return None
145
+
146
+
147
+ def source_category_error(value: Any) -> str | None:
148
+ if value is None or value == "":
149
+ return None
150
+ if not isinstance(value, str):
151
+ return "must be a string"
152
+ if value.strip() not in VALID_SOURCE_CATEGORIES:
153
+ return f"must be one of {sorted(VALID_SOURCE_CATEGORIES)}"
154
+ return None
155
+
156
+
157
+ def retrieval_source_type_error(value: Any) -> str | None:
158
+ if value is None or value == "":
159
+ return None
160
+ if not isinstance(value, str):
161
+ return "must be a string"
162
+ if value.strip() not in VALID_RETRIEVAL_SOURCE_TYPES:
163
+ return f"must be one of {sorted(VALID_RETRIEVAL_SOURCE_TYPES)}"
164
+ return None
165
+
166
+
167
+ def underlying_evidence_type_error(value: Any) -> str | None:
168
+ if value is None or value == "":
169
+ return None
170
+ if not isinstance(value, str):
171
+ return "must be a string"
172
+ if value.strip() not in VALID_UNDERLYING_EVIDENCE_TYPES:
173
+ return f"must be one of {sorted(VALID_UNDERLYING_EVIDENCE_TYPES)}"
174
+ return None
175
+
176
+
177
+ def normalize_source_category(*values: Any, default: str = "other") -> str:
178
+ for value in values:
179
+ normalized = _taxonomy_key(value)
180
+ if not normalized:
181
+ continue
182
+ if normalized in VALID_SOURCE_CATEGORIES:
183
+ return normalized
184
+ if normalized in SOURCE_CATEGORY_ALIASES:
185
+ return SOURCE_CATEGORY_ALIASES[normalized]
186
+ return default
187
+
188
+
189
+ def normalize_retrieval_source_type(*values: Any, default: str = "other") -> str:
190
+ for value in values:
191
+ normalized = _taxonomy_key(value)
192
+ if not normalized:
193
+ continue
194
+ if normalized in VALID_RETRIEVAL_SOURCE_TYPES:
195
+ return normalized
196
+ if normalized in RETRIEVAL_SOURCE_TYPE_ALIASES:
197
+ return RETRIEVAL_SOURCE_TYPE_ALIASES[normalized]
198
+ return default
199
+
200
+
201
+ def normalize_underlying_evidence_type(*values: Any, default: str = "unknown") -> str:
202
+ for value in values:
203
+ normalized = _taxonomy_key(value)
204
+ if not normalized:
205
+ continue
206
+ if normalized in VALID_UNDERLYING_EVIDENCE_TYPES:
207
+ return normalized
208
+ if normalized in UNDERLYING_EVIDENCE_TYPE_ALIASES:
209
+ return UNDERLYING_EVIDENCE_TYPE_ALIASES[normalized]
210
+ return default
211
+
212
+
213
+ def _taxonomy_key(value: Any) -> str:
214
+ if not isinstance(value, str):
215
+ return ""
216
+ return re.sub(r"[^a-z0-9]+", "_", value.strip().lower()).strip("_")
217
+
218
+
219
+ def has_valid_source_url(record: Mapping[str, Any]) -> bool:
220
+ value = record.get("source_url")
221
+ return non_empty_text(value) and source_url_error(value) is None
222
+
223
+
224
+ def source_category_missing(record: Mapping[str, Any]) -> bool:
225
+ return not non_empty_text(record.get(SOURCE_CATEGORY_FIELD))
226
+
227
+
228
+ def local_file_without_url_missing_identity(
229
+ record: Mapping[str, Any],
230
+ *,
231
+ default_source_type: str | None = None,
232
+ ) -> str | None:
233
+ source_type = record.get("source_type")
234
+ if isinstance(source_type, str):
235
+ normalized_source_type = source_type.strip() or default_source_type
236
+ elif source_type is None:
237
+ normalized_source_type = default_source_type
238
+ else:
239
+ return None
240
+ if not normalized_source_type:
241
+ return None
242
+ if normalized_source_type != "local_file":
243
+ return None
244
+ if has_valid_source_url(record):
245
+ return None
246
+ if source_category_missing(record):
247
+ return SOURCE_CATEGORY_FIELD
248
+ if not (
249
+ non_empty_text(record.get("source_title")) or non_empty_text(record.get("source_name"))
250
+ ):
251
+ return "source_title_or_source_name"
252
+ return None