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.
- briefloop-0.11.12.dist-info/METADATA +473 -0
- briefloop-0.11.12.dist-info/RECORD +424 -0
- briefloop-0.11.12.dist-info/WHEEL +5 -0
- briefloop-0.11.12.dist-info/entry_points.txt +3 -0
- briefloop-0.11.12.dist-info/licenses/LICENSE +22 -0
- briefloop-0.11.12.dist-info/top_level.txt +1 -0
- multi_agent_brief/__init__.py +36 -0
- multi_agent_brief/analysis_blocks/__init__.py +11 -0
- multi_agent_brief/analysis_blocks/builder.py +206 -0
- multi_agent_brief/analysis_blocks/renderer.py +237 -0
- multi_agent_brief/analysis_blocks/schemas.py +52 -0
- multi_agent_brief/analysis_modules/__init__.py +8 -0
- multi_agent_brief/analysis_modules/base.py +87 -0
- multi_agent_brief/analysis_modules/market_competitor/__init__.py +68 -0
- multi_agent_brief/analysis_modules/market_competitor/auditor.py +290 -0
- multi_agent_brief/analysis_modules/market_competitor/config.py +187 -0
- multi_agent_brief/analysis_modules/market_competitor/event_builder.py +226 -0
- multi_agent_brief/analysis_modules/market_competitor/renderer.py +199 -0
- multi_agent_brief/analysis_modules/market_competitor/schemas.py +518 -0
- multi_agent_brief/analysis_modules/policy_regulatory/__init__.py +7 -0
- multi_agent_brief/analysis_modules/policy_regulatory/audit.py +195 -0
- multi_agent_brief/analysis_modules/policy_regulatory/module.py +387 -0
- multi_agent_brief/analysis_modules/policy_regulatory/schemas.py +129 -0
- multi_agent_brief/analysis_modules/registry.py +73 -0
- multi_agent_brief/audience/__init__.py +19 -0
- multi_agent_brief/audience/profiles.py +246 -0
- multi_agent_brief/audience_memory/__init__.py +23 -0
- multi_agent_brief/audience_memory/profile.py +358 -0
- multi_agent_brief/audit/__init__.py +36 -0
- multi_agent_brief/audit/case_applicability.py +181 -0
- multi_agent_brief/audit/deterministic.py +471 -0
- multi_agent_brief/audit/editorial_governance.py +404 -0
- multi_agent_brief/audit/final_quality.py +764 -0
- multi_agent_brief/audit/harness.py +242 -0
- multi_agent_brief/audit/interfaces.py +96 -0
- multi_agent_brief/audit/limitation_hygiene.py +238 -0
- multi_agent_brief/audit/proposal_boundary.py +34 -0
- multi_agent_brief/audit/redaction.py +27 -0
- multi_agent_brief/audit/rule_packs.py +96 -0
- multi_agent_brief/audit/semantic.py +435 -0
- multi_agent_brief/capabilities/__init__.py +22 -0
- multi_agent_brief/capabilities/catalog.py +215 -0
- multi_agent_brief/capabilities/detect.py +199 -0
- multi_agent_brief/capabilities/models.py +60 -0
- multi_agent_brief/capabilities/recommend.py +206 -0
- multi_agent_brief/cli/__init__.py +2 -0
- multi_agent_brief/cli/analysis_commands.py +140 -0
- multi_agent_brief/cli/approval_commands.py +107 -0
- multi_agent_brief/cli/audit_commands.py +59 -0
- multi_agent_brief/cli/capability_commands.py +548 -0
- multi_agent_brief/cli/claude_commands.py +159 -0
- multi_agent_brief/cli/competitors_commands.py +182 -0
- multi_agent_brief/cli/controls_commands.py +137 -0
- multi_agent_brief/cli/deliver_commands.py +942 -0
- multi_agent_brief/cli/eval_cases_commands.py +99 -0
- multi_agent_brief/cli/experiments_commands.py +395 -0
- multi_agent_brief/cli/feedback_commands.py +192 -0
- multi_agent_brief/cli/finalize_commands.py +153 -0
- multi_agent_brief/cli/gates_commands.py +174 -0
- multi_agent_brief/cli/hermes_commands.py +356 -0
- multi_agent_brief/cli/improve_commands.py +224 -0
- multi_agent_brief/cli/init_commands.py +564 -0
- multi_agent_brief/cli/init_wizard.py +1473 -0
- multi_agent_brief/cli/input_commands.py +237 -0
- multi_agent_brief/cli/main.py +288 -0
- multi_agent_brief/cli/onboard_commands.py +193 -0
- multi_agent_brief/cli/product_commands.py +1449 -0
- multi_agent_brief/cli/provenance_commands.py +100 -0
- multi_agent_brief/cli/release_commands.py +68 -0
- multi_agent_brief/cli/repair_commands.py +169 -0
- multi_agent_brief/cli/run_commands.py +292 -0
- multi_agent_brief/cli/runtime_commands.py +81 -0
- multi_agent_brief/cli/secrets_commands.py +232 -0
- multi_agent_brief/cli/semantic_support_commands.py +80 -0
- multi_agent_brief/cli/sources_commands.py +647 -0
- multi_agent_brief/cli/start_commands.py +8 -0
- multi_agent_brief/cli/state_commands.py +446 -0
- multi_agent_brief/cli/status_commands.py +26 -0
- multi_agent_brief/cli/workbuddy_commands.py +103 -0
- multi_agent_brief/configs/artifact_contracts.yaml +514 -0
- multi_agent_brief/configs/orchestrator_contract.yaml +181 -0
- multi_agent_brief/configs/policy_packs/default.yaml +65 -0
- multi_agent_brief/configs/policy_profiles/evidence_extract_default.yaml +58 -0
- multi_agent_brief/configs/policy_profiles/finance_default.yaml +44 -0
- multi_agent_brief/configs/policy_profiles/internet_default.yaml +44 -0
- multi_agent_brief/configs/policy_profiles/manufacturing_default.yaml +33 -0
- multi_agent_brief/configs/policy_profiles/solar_manufacturing_default.yaml +64 -0
- multi_agent_brief/configs/report_packs/evidence_extract.yaml +48 -0
- multi_agent_brief/configs/report_packs/management_monthly.yaml +36 -0
- multi_agent_brief/configs/report_packs/market_weekly.yaml +36 -0
- multi_agent_brief/configs/report_packs/solar_industry_periodic.yaml +50 -0
- multi_agent_brief/configs/report_templates/evidence_extract.yaml +55 -0
- multi_agent_brief/configs/report_templates/management_monthly.yaml +48 -0
- multi_agent_brief/configs/report_templates/market_weekly.yaml +49 -0
- multi_agent_brief/configs/report_templates/solar_industry_periodic.yaml +75 -0
- multi_agent_brief/configs/stage_specs.yaml +180 -0
- multi_agent_brief/contracts/__init__.py +41 -0
- multi_agent_brief/contracts/base.py +99 -0
- multi_agent_brief/contracts/errors.py +41 -0
- multi_agent_brief/contracts/migrations/__init__.py +5 -0
- multi_agent_brief/contracts/migrations/claim_v1_to_v2.py +33 -0
- multi_agent_brief/contracts/registry.py +159 -0
- multi_agent_brief/contracts/role_topology.py +25 -0
- multi_agent_brief/contracts/schemas/__init__.py +35 -0
- multi_agent_brief/contracts/schemas/analysis_pack.py +135 -0
- multi_agent_brief/contracts/schemas/atomic_claim_graph.py +304 -0
- multi_agent_brief/contracts/schemas/audit_report.py +80 -0
- multi_agent_brief/contracts/schemas/candidate_item.py +51 -0
- multi_agent_brief/contracts/schemas/claim.py +197 -0
- multi_agent_brief/contracts/schemas/claim_draft.py +386 -0
- multi_agent_brief/contracts/schemas/claim_support_matrix.py +334 -0
- multi_agent_brief/contracts/schemas/evidence_span_registry.py +270 -0
- multi_agent_brief/contracts/schemas/policy_profile.py +247 -0
- multi_agent_brief/contracts/schemas/report_spec.py +257 -0
- multi_agent_brief/contracts/schemas/semantic_assessment_report.py +480 -0
- multi_agent_brief/contracts/schemas/source_evidence_pack_manifest.py +233 -0
- multi_agent_brief/contracts/schemas/source_item.py +96 -0
- multi_agent_brief/contracts/semantic_assessment_status.py +12 -0
- multi_agent_brief/contracts/source_metadata.py +252 -0
- multi_agent_brief/contracts/target_contract.py +460 -0
- multi_agent_brief/contracts/validator.py +225 -0
- multi_agent_brief/controls/__init__.py +23 -0
- multi_agent_brief/controls/contract.py +106 -0
- multi_agent_brief/controls/switchboard.py +1076 -0
- multi_agent_brief/core/__init__.py +2 -0
- multi_agent_brief/core/citations.py +14 -0
- multi_agent_brief/core/claim_ledger.py +94 -0
- multi_agent_brief/core/config.py +191 -0
- multi_agent_brief/core/env.py +69 -0
- multi_agent_brief/core/previous.py +83 -0
- multi_agent_brief/core/schemas.py +181 -0
- multi_agent_brief/core/selection.py +189 -0
- multi_agent_brief/delivery/__init__.py +6 -0
- multi_agent_brief/delivery/base.py +36 -0
- multi_agent_brief/delivery/feishu.py +204 -0
- multi_agent_brief/delivery/gws.py +237 -0
- multi_agent_brief/evaluation_cases/__init__.py +15 -0
- multi_agent_brief/evaluation_cases/contract.py +429 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/config.yaml +18 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/improvement/ledger.jsonl +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/approved_guidance_materialized/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/company_event_missing_latest_official_check/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/config.yaml +12 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/sources.yaml +6 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/control_switchboard_selection_is_not_execution/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/config.yaml +6 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/input/human_feedback.md +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/feedback_triage_required/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/config.yaml +8 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/brief.md +14 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/audited_brief.md +5 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/claim_ledger.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/final_abstract_quality_warning_surface/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/formal_release_missing_human_approval/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/config.yaml +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/guidance_manifestation_not_observable/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/media_only_legal_policy_blocks_research_review/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/mixed_metric_scope_support_blocker/workspace/user.md +5 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/config.yaml +6 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/audited_brief.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/claim_ledger.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/feedback_issues.json +25 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/repair_plan.json +27 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/planned_blocking_issue_cannot_continue/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/config.yaml +8 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/audited_brief.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/claim_ledger.json +11 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/quality_gate_report.json +22 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/provenance_projection_minimal/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/audited_brief.md +5 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/claim_ledger.json +40 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/sources.yaml +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_source_appendix/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/config.yaml +8 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/brief.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/audited_brief.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/claim_ledger.json +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reader_facing_target_relevance/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/output/intermediate/release_readiness_report.json +31 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/release_readiness_forged_event_blocker/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/config.yaml +18 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/improvement/ledger.jsonl +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/improvement/memory.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/output/intermediate/improvement_memory_snapshot.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/reverted_entry_removed_from_next_snapshot/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/config.yaml +12 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/input/sources/source-001.txt +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/brief.md +37 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/delivery/brief.md +37 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/atomic_claim_graph.json +17 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/audit_report.json +5 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/audited_brief.md +37 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/claim_ledger.json +20 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/evidence_span_registry.json +20 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/finalize_report.json +40 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/gates/auditor_quality_gate_report.json +42 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/gates/finalize_quality_gate_report.json +42 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/intermediate/screened_candidates.json +33 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/source_appendix.md +12 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/output/source_appendix_trace.md +10 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/report_spec.yaml +24 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/sources.yaml +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/same_evidence_reader_quality_regression/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/input/sources/README.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/output/intermediate/source_evidence_pack_manifest.json +26 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/source_evidence_pack_blocks_non_evidence_file/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/config.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/audited_brief.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/claim_ledger.json +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/stale_current_claim/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/config.yaml +13 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/third_party_price_snapshot_formal_block/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/config.yaml +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/trajectory_retry_budget_exhausted/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/config.yaml +18 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/improvement/ledger.jsonl +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unapproved_entry_not_materialized/workspace/user.md +4 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/config.yaml +18 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/sources.yaml +9 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unauthorized_institution_branding_blocks_release/workspace/user.md +5 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/config.yaml +8 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/audit_report.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/audited_brief.md +8 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/candidate_claims.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/claim_ledger.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/output/intermediate/screened_candidates.json +1 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/sources.yaml +2 -0
- multi_agent_brief/evaluation_cases/fixtures/cases/unsupported_material_fact/workspace/user.md +3 -0
- multi_agent_brief/evaluation_cases/fixtures/manifest.yaml +861 -0
- multi_agent_brief/evaluation_cases/fixtures.py +20 -0
- multi_agent_brief/evaluation_cases/runner.py +1603 -0
- multi_agent_brief/experiments/__init__.py +45 -0
- multi_agent_brief/experiments/experiment_080.py +5835 -0
- multi_agent_brief/experiments/schemas.py +63 -0
- multi_agent_brief/experiments/target_contract.py +10 -0
- multi_agent_brief/feedback/__init__.py +17 -0
- multi_agent_brief/feedback/feedback_contract.py +482 -0
- multi_agent_brief/feedback/feedback_state.py +898 -0
- multi_agent_brief/hermes/__init__.py +25 -0
- multi_agent_brief/hermes/adapter.py +832 -0
- multi_agent_brief/improvement/__init__.py +83 -0
- multi_agent_brief/improvement/contract.py +1114 -0
- multi_agent_brief/improvement/memory.py +451 -0
- multi_agent_brief/improvement/product_definition.py +228 -0
- multi_agent_brief/improvement/state.py +961 -0
- multi_agent_brief/inputs/__init__.py +2 -0
- multi_agent_brief/inputs/classifier.py +322 -0
- multi_agent_brief/inputs/contracts.py +59 -0
- multi_agent_brief/inputs/extractor.py +310 -0
- multi_agent_brief/install/__init__.py +2 -0
- multi_agent_brief/install/writer.py +97 -0
- multi_agent_brief/onboarding/__init__.py +11 -0
- multi_agent_brief/onboarding/io.py +103 -0
- multi_agent_brief/onboarding/mapper.py +484 -0
- multi_agent_brief/onboarding/schema.py +46 -0
- multi_agent_brief/orchestrator/__init__.py +2 -0
- multi_agent_brief/orchestrator/fact_layer_import.py +352 -0
- multi_agent_brief/orchestrator/handoff.py +2209 -0
- multi_agent_brief/orchestrator/role_topology.py +42 -0
- multi_agent_brief/orchestrator/run_archive.py +888 -0
- multi_agent_brief/orchestrator/run_integrity.py +346 -0
- multi_agent_brief/orchestrator/runtime_state/__init__.py +70 -0
- multi_agent_brief/orchestrator/runtime_state/_io.py +167 -0
- multi_agent_brief/orchestrator/runtime_state/_transactions.py +298 -0
- multi_agent_brief/orchestrator/runtime_state/artifact_registry.py +1825 -0
- multi_agent_brief/orchestrator/runtime_state/atomic_claim_graph.py +96 -0
- multi_agent_brief/orchestrator/runtime_state/claim_ledger_freeze.py +510 -0
- multi_agent_brief/orchestrator/runtime_state/claim_metadata_enrichment.py +836 -0
- multi_agent_brief/orchestrator/runtime_state/claim_support_matrix.py +582 -0
- multi_agent_brief/orchestrator/runtime_state/completion_gates.py +672 -0
- multi_agent_brief/orchestrator/runtime_state/contracts_loader.py +66 -0
- multi_agent_brief/orchestrator/runtime_state/decisions.py +239 -0
- multi_agent_brief/orchestrator/runtime_state/errors.py +61 -0
- multi_agent_brief/orchestrator/runtime_state/event_log.py +256 -0
- multi_agent_brief/orchestrator/runtime_state/evidence_span_registry.py +233 -0
- multi_agent_brief/orchestrator/runtime_state/fact_layer.py +755 -0
- multi_agent_brief/orchestrator/runtime_state/identity.py +90 -0
- multi_agent_brief/orchestrator/runtime_state/lifecycle.py +675 -0
- multi_agent_brief/orchestrator/runtime_state/manifest.py +82 -0
- multi_agent_brief/orchestrator/runtime_state/operations.py +224 -0
- multi_agent_brief/orchestrator/runtime_state/paths.py +38 -0
- multi_agent_brief/orchestrator/runtime_state/repair.py +984 -0
- multi_agent_brief/orchestrator/runtime_state/safety_surfaces.py +147 -0
- multi_agent_brief/orchestrator/runtime_state/semantic_assessment_report.py +692 -0
- multi_agent_brief/orchestrator/runtime_state/semantic_support_acceptance.py +683 -0
- multi_agent_brief/orchestrator/runtime_state/source_evidence_pack.py +131 -0
- multi_agent_brief/orchestrator/runtime_state/stage_completion.py +1320 -0
- multi_agent_brief/orchestrator/runtime_state/trajectory.py +200 -0
- multi_agent_brief/orchestrator/runtime_state/workflow.py +350 -0
- multi_agent_brief/orchestrator/source_evidence.py +43 -0
- multi_agent_brief/orchestrator/timing.py +410 -0
- multi_agent_brief/orchestrator_contract.py +96 -0
- multi_agent_brief/outputs/__init__.py +2 -0
- multi_agent_brief/outputs/atomic_reader_projection.py +288 -0
- multi_agent_brief/outputs/docx.py +32 -0
- multi_agent_brief/outputs/finalize.py +1036 -0
- multi_agent_brief/outputs/ib_docx.py +983 -0
- multi_agent_brief/outputs/naming.py +38 -0
- multi_agent_brief/outputs/pdf.py +20 -0
- multi_agent_brief/outputs/reader_final_gate.py +509 -0
- multi_agent_brief/outputs/reader_projection.py +397 -0
- multi_agent_brief/outputs/source_appendix.py +753 -0
- multi_agent_brief/outputs/templates/__init__.py +112 -0
- multi_agent_brief/product/__init__.py +49 -0
- multi_agent_brief/product/bundle_projection.py +686 -0
- multi_agent_brief/product/citation_profile.py +145 -0
- multi_agent_brief/product/guidance_manifestation.py +421 -0
- multi_agent_brief/product/materiality_selection.py +472 -0
- multi_agent_brief/product/policy_gate_adapter.py +116 -0
- multi_agent_brief/product/policy_profile.py +39 -0
- multi_agent_brief/product/policy_projection.py +161 -0
- multi_agent_brief/product/policy_registry.py +83 -0
- multi_agent_brief/product/policy_resolver.py +225 -0
- multi_agent_brief/product/quality_closeout.py +188 -0
- multi_agent_brief/product/quality_panel.py +2217 -0
- multi_agent_brief/product/release_approval.py +1034 -0
- multi_agent_brief/product/report_pack.py +130 -0
- multi_agent_brief/product/report_pack_aliases.py +68 -0
- multi_agent_brief/product/report_registry.py +101 -0
- multi_agent_brief/product/report_spec.py +181 -0
- multi_agent_brief/product/support_wording.py +525 -0
- multi_agent_brief/product/template_conformance.py +516 -0
- multi_agent_brief/product/template_projection.py +123 -0
- multi_agent_brief/product/template_registry.py +244 -0
- multi_agent_brief/product/template_render_plan.py +315 -0
- multi_agent_brief/product/template_renderer.py +224 -0
- multi_agent_brief/product/trajectory_regulation.py +441 -0
- multi_agent_brief/provenance/__init__.py +5 -0
- multi_agent_brief/provenance/builder.py +841 -0
- multi_agent_brief/provenance/contract.py +21 -0
- multi_agent_brief/provenance/io.py +144 -0
- multi_agent_brief/provenance/model.py +110 -0
- multi_agent_brief/provenance/references.py +43 -0
- multi_agent_brief/provenance/validator.py +135 -0
- multi_agent_brief/quality_gates/__init__.py +19 -0
- multi_agent_brief/quality_gates/contract.py +581 -0
- multi_agent_brief/quality_gates/state.py +2498 -0
- multi_agent_brief/repair/__init__.py +5 -0
- multi_agent_brief/repair/router.py +842 -0
- multi_agent_brief/runtime_assets.py +431 -0
- multi_agent_brief/sources/__init__.py +16 -0
- multi_agent_brief/sources/api_filings.py +236 -0
- multi_agent_brief/sources/api_news.py +174 -0
- multi_agent_brief/sources/base.py +142 -0
- multi_agent_brief/sources/cached_package.py +119 -0
- multi_agent_brief/sources/cli_provider.py +263 -0
- multi_agent_brief/sources/coverage.py +336 -0
- multi_agent_brief/sources/decider.py +756 -0
- multi_agent_brief/sources/doctor.py +373 -0
- multi_agent_brief/sources/evidence_pack.py +364 -0
- multi_agent_brief/sources/feishu_provider.py +326 -0
- multi_agent_brief/sources/filing_resolver.py +400 -0
- multi_agent_brief/sources/industry_packs.py +130 -0
- multi_agent_brief/sources/join.py +206 -0
- multi_agent_brief/sources/local_signal.py +81 -0
- multi_agent_brief/sources/local_signal_planner.py +636 -0
- multi_agent_brief/sources/manual.py +259 -0
- multi_agent_brief/sources/mcp_provider.py +309 -0
- multi_agent_brief/sources/mineru_provider.py +601 -0
- multi_agent_brief/sources/normalizer.py +95 -0
- multi_agent_brief/sources/opencli_provider.py +282 -0
- multi_agent_brief/sources/planner.py +178 -0
- multi_agent_brief/sources/registry.py +367 -0
- multi_agent_brief/sources/rss.py +190 -0
- multi_agent_brief/sources/search_backends/__init__.py +31 -0
- multi_agent_brief/sources/search_backends/base.py +51 -0
- multi_agent_brief/sources/search_backends/brave.py +192 -0
- multi_agent_brief/sources/search_backends/capabilities.py +94 -0
- multi_agent_brief/sources/search_backends/exa.py +180 -0
- multi_agent_brief/sources/search_backends/firecrawl.py +164 -0
- multi_agent_brief/sources/search_backends/serper.py +241 -0
- multi_agent_brief/sources/search_backends/tavily.py +124 -0
- multi_agent_brief/sources/sourcehub.py +505 -0
- multi_agent_brief/sources/web_search.py +267 -0
- multi_agent_brief/status.py +966 -0
- multi_agent_brief/tools/__init__.py +3 -0
- multi_agent_brief/tools/draft_cleanup.py +198 -0
- multi_agent_brief/workbuddy/__init__.py +1 -0
- multi_agent_brief/workbuddy/diagnose.py +569 -0
- multi_agent_brief/workbuddy/skill_pack.py +309 -0
- multi_agent_brief/workspace/__init__.py +1 -0
- multi_agent_brief/workspace/init_profile.py +45 -0
|
@@ -0,0 +1,346 @@
|
|
|
1
|
+
"""Shared run integrity helpers for runtime control surfaces."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
RUN_INTEGRITY_CLEAN = "clean"
|
|
11
|
+
RUN_INTEGRITY_CONTAMINATED = "contaminated"
|
|
12
|
+
RUN_INTEGRITY_CONTAMINATED_REPAIRED = "contaminated_repaired"
|
|
13
|
+
RUN_INTEGRITY_UNKNOWN = "unknown"
|
|
14
|
+
PERSISTED_RUN_INTEGRITY_STATUSES = {
|
|
15
|
+
RUN_INTEGRITY_CLEAN,
|
|
16
|
+
RUN_INTEGRITY_CONTAMINATED,
|
|
17
|
+
RUN_INTEGRITY_CONTAMINATED_REPAIRED,
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
@dataclass(frozen=True)
|
|
22
|
+
class RunIntegrityVerdict:
|
|
23
|
+
"""Single interpreter result for persisted and read-side run integrity."""
|
|
24
|
+
|
|
25
|
+
kind: str
|
|
26
|
+
value: dict[str, Any]
|
|
27
|
+
reason_code: str | None = None
|
|
28
|
+
message: str | None = None
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _clean_run_integrity() -> dict[str, Any]:
|
|
32
|
+
"""Return the canonical clean run-integrity payload."""
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
"status": RUN_INTEGRITY_CLEAN,
|
|
36
|
+
"reference_eligible": True,
|
|
37
|
+
"clean_single_shot": True,
|
|
38
|
+
"reasons": [],
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _unknown_run_integrity(*, reason_code: str, message: str) -> dict[str, Any]:
|
|
43
|
+
"""Return a derived unknown integrity payload for read-only surfaces."""
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
"status": RUN_INTEGRITY_UNKNOWN,
|
|
47
|
+
"reference_eligible": False,
|
|
48
|
+
"clean_single_shot": False,
|
|
49
|
+
"reasons": [{"reason_code": reason_code, "message": message}],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _degraded(reason_code: str, message: str) -> RunIntegrityVerdict:
|
|
54
|
+
return RunIntegrityVerdict(
|
|
55
|
+
kind="degraded",
|
|
56
|
+
value=_unknown_run_integrity(reason_code=reason_code, message=message),
|
|
57
|
+
reason_code=reason_code,
|
|
58
|
+
message=message,
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def interpret_run_integrity(
|
|
63
|
+
value: Any,
|
|
64
|
+
*,
|
|
65
|
+
field_present: bool,
|
|
66
|
+
unavailable_reason: dict[str, str] | None = None,
|
|
67
|
+
) -> RunIntegrityVerdict:
|
|
68
|
+
"""Interpret a run_integrity field once for read and write adapters.
|
|
69
|
+
|
|
70
|
+
Missing legacy fields are backcompat-clean. Present malformed fields are
|
|
71
|
+
degraded for read surfaces and rejected by ``require_persistable``.
|
|
72
|
+
"""
|
|
73
|
+
|
|
74
|
+
if unavailable_reason:
|
|
75
|
+
return _degraded(
|
|
76
|
+
unavailable_reason.get("reason_code") or "run_integrity_unavailable",
|
|
77
|
+
unavailable_reason.get("message") or "workflow_state.run_integrity is unavailable.",
|
|
78
|
+
)
|
|
79
|
+
if not field_present:
|
|
80
|
+
return RunIntegrityVerdict(kind="canonical", value=_clean_run_integrity())
|
|
81
|
+
if not isinstance(value, dict):
|
|
82
|
+
return _degraded(
|
|
83
|
+
"run_integrity_malformed",
|
|
84
|
+
"workflow_state.run_integrity is missing or not an object.",
|
|
85
|
+
)
|
|
86
|
+
status = value.get("status")
|
|
87
|
+
if status not in PERSISTED_RUN_INTEGRITY_STATUSES:
|
|
88
|
+
return _degraded(
|
|
89
|
+
"run_integrity_invalid_status",
|
|
90
|
+
"workflow_state.run_integrity.status is invalid.",
|
|
91
|
+
)
|
|
92
|
+
reasons = value.get("reasons", [])
|
|
93
|
+
if not isinstance(reasons, list) or any(not isinstance(item, dict) for item in reasons):
|
|
94
|
+
return _degraded(
|
|
95
|
+
"run_integrity_invalid_reasons",
|
|
96
|
+
"workflow_state.run_integrity.reasons must be a list of objects.",
|
|
97
|
+
)
|
|
98
|
+
if status == RUN_INTEGRITY_CLEAN:
|
|
99
|
+
if value.get("reference_eligible", True) is not True:
|
|
100
|
+
return _degraded(
|
|
101
|
+
"run_integrity_clean_not_reference_eligible",
|
|
102
|
+
"workflow_state.run_integrity clean runs must be reference eligible.",
|
|
103
|
+
)
|
|
104
|
+
if value.get("clean_single_shot", True) is not True:
|
|
105
|
+
return _degraded(
|
|
106
|
+
"run_integrity_clean_not_single_shot",
|
|
107
|
+
"workflow_state.run_integrity clean runs must be clean single-shot.",
|
|
108
|
+
)
|
|
109
|
+
return RunIntegrityVerdict(
|
|
110
|
+
kind="canonical",
|
|
111
|
+
value={
|
|
112
|
+
"status": RUN_INTEGRITY_CLEAN,
|
|
113
|
+
"reference_eligible": True,
|
|
114
|
+
"clean_single_shot": True,
|
|
115
|
+
"reasons": reasons,
|
|
116
|
+
},
|
|
117
|
+
)
|
|
118
|
+
if value.get("reference_eligible", False) is not False:
|
|
119
|
+
return _degraded(
|
|
120
|
+
"run_integrity_contaminated_reference_eligible",
|
|
121
|
+
"workflow_state.run_integrity non-clean runs must not be reference eligible.",
|
|
122
|
+
)
|
|
123
|
+
if value.get("clean_single_shot", False) is not False:
|
|
124
|
+
return _degraded(
|
|
125
|
+
"run_integrity_contaminated_single_shot",
|
|
126
|
+
"workflow_state.run_integrity non-clean runs must not be clean single-shot.",
|
|
127
|
+
)
|
|
128
|
+
return RunIntegrityVerdict(
|
|
129
|
+
kind="canonical",
|
|
130
|
+
value={
|
|
131
|
+
"status": status,
|
|
132
|
+
"reference_eligible": False,
|
|
133
|
+
"clean_single_shot": False,
|
|
134
|
+
"reasons": reasons,
|
|
135
|
+
},
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def project_for_read(verdict: RunIntegrityVerdict) -> dict[str, Any]:
|
|
140
|
+
"""Return the read-side projection for a run-integrity verdict."""
|
|
141
|
+
|
|
142
|
+
return dict(verdict.value)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
def require_persistable(
|
|
146
|
+
verdict: RunIntegrityVerdict,
|
|
147
|
+
*,
|
|
148
|
+
path: str | Path = "workflow_state.json",
|
|
149
|
+
) -> dict[str, Any]:
|
|
150
|
+
"""Return canonical persisted payload or fail closed for malformed fields."""
|
|
151
|
+
|
|
152
|
+
if verdict.kind != "canonical":
|
|
153
|
+
from multi_agent_brief.orchestrator.runtime_state.errors import (
|
|
154
|
+
E_TRANSACTION_INTEGRITY,
|
|
155
|
+
RuntimeStateError,
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
raise RuntimeStateError(
|
|
159
|
+
"workflow_state.run_integrity is malformed.",
|
|
160
|
+
details={"path": str(path), "reason": verdict.message or verdict.reason_code or "invalid run_integrity"},
|
|
161
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
162
|
+
)
|
|
163
|
+
return dict(verdict.value)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def workflow_with_persistable_run_integrity(workflow: dict[str, Any], *, path: str | Path) -> dict[str, Any]:
|
|
167
|
+
"""Return a shallow workflow copy with write-safe run integrity."""
|
|
168
|
+
|
|
169
|
+
updated = dict(workflow)
|
|
170
|
+
updated["run_integrity"] = require_persistable(
|
|
171
|
+
interpret_run_integrity(
|
|
172
|
+
updated.get("run_integrity"),
|
|
173
|
+
field_present="run_integrity" in updated,
|
|
174
|
+
),
|
|
175
|
+
path=path,
|
|
176
|
+
)
|
|
177
|
+
return updated
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
def workflow_with_sticky_contamination_events(
|
|
181
|
+
workflow: dict[str, Any],
|
|
182
|
+
event_records: list[dict[str, Any]],
|
|
183
|
+
) -> dict[str, Any]:
|
|
184
|
+
"""Return workflow with run-integrity contamination replayed from events."""
|
|
185
|
+
|
|
186
|
+
updated = workflow_with_persistable_run_integrity(
|
|
187
|
+
workflow,
|
|
188
|
+
path="workflow_state.run_integrity",
|
|
189
|
+
)
|
|
190
|
+
contamination_events = [
|
|
191
|
+
event
|
|
192
|
+
for event in event_records
|
|
193
|
+
if isinstance(event, dict) and event.get("event_type") == "run_integrity_contaminated"
|
|
194
|
+
]
|
|
195
|
+
if not contamination_events:
|
|
196
|
+
return updated
|
|
197
|
+
|
|
198
|
+
integrity = require_persistable(
|
|
199
|
+
interpret_run_integrity(updated.get("run_integrity"), field_present=True),
|
|
200
|
+
path="workflow_state.run_integrity",
|
|
201
|
+
)
|
|
202
|
+
existing = integrity.get("reasons") if isinstance(integrity.get("reasons"), list) else []
|
|
203
|
+
reasons = [item for item in existing if isinstance(item, dict)]
|
|
204
|
+
seen = {
|
|
205
|
+
(
|
|
206
|
+
str(item.get("reason_code") or ""),
|
|
207
|
+
str(item.get("message") or ""),
|
|
208
|
+
str(item.get("stage_id") or ""),
|
|
209
|
+
str(item.get("artifact_id") or ""),
|
|
210
|
+
)
|
|
211
|
+
for item in reasons
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
for event in contamination_events:
|
|
215
|
+
metadata = event.get("metadata") if isinstance(event.get("metadata"), dict) else {}
|
|
216
|
+
reason = {
|
|
217
|
+
"reason_code": str(metadata.get("reason_code") or "run_integrity_contaminated"),
|
|
218
|
+
"message": str(
|
|
219
|
+
metadata.get("message")
|
|
220
|
+
or event.get("reason")
|
|
221
|
+
or "Run integrity contamination event was recorded."
|
|
222
|
+
),
|
|
223
|
+
"created_at": str(event.get("created_at") or ""),
|
|
224
|
+
}
|
|
225
|
+
stage_id = metadata.get("stage_id") or event.get("stage_id")
|
|
226
|
+
artifact_id = metadata.get("artifact_id") or event.get("artifact_id")
|
|
227
|
+
if stage_id:
|
|
228
|
+
reason["stage_id"] = str(stage_id)
|
|
229
|
+
if artifact_id:
|
|
230
|
+
reason["artifact_id"] = str(artifact_id)
|
|
231
|
+
details = metadata.get("details")
|
|
232
|
+
if isinstance(details, dict) and details:
|
|
233
|
+
reason["metadata"] = details
|
|
234
|
+
marker = (
|
|
235
|
+
reason["reason_code"],
|
|
236
|
+
reason["message"],
|
|
237
|
+
str(reason.get("stage_id") or ""),
|
|
238
|
+
str(reason.get("artifact_id") or ""),
|
|
239
|
+
)
|
|
240
|
+
if marker in seen:
|
|
241
|
+
continue
|
|
242
|
+
seen.add(marker)
|
|
243
|
+
reasons.append(reason)
|
|
244
|
+
|
|
245
|
+
sticky_status = (
|
|
246
|
+
RUN_INTEGRITY_CONTAMINATED
|
|
247
|
+
if integrity.get("status") == RUN_INTEGRITY_CLEAN
|
|
248
|
+
else str(integrity.get("status"))
|
|
249
|
+
)
|
|
250
|
+
integrity.update({
|
|
251
|
+
"status": sticky_status,
|
|
252
|
+
"reference_eligible": False,
|
|
253
|
+
"clean_single_shot": False,
|
|
254
|
+
"reasons": reasons,
|
|
255
|
+
})
|
|
256
|
+
updated["run_integrity"] = integrity
|
|
257
|
+
return updated
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
def finalize_run_integrity(workflow: dict[str, Any]) -> dict[str, Any]:
|
|
261
|
+
"""Mark a completed contaminated run as repaired but not reference-eligible."""
|
|
262
|
+
|
|
263
|
+
updated = workflow_with_persistable_run_integrity(
|
|
264
|
+
workflow,
|
|
265
|
+
path="workflow_state.run_integrity",
|
|
266
|
+
)
|
|
267
|
+
integrity = require_persistable(
|
|
268
|
+
interpret_run_integrity(updated.get("run_integrity"), field_present=True),
|
|
269
|
+
path="workflow_state.run_integrity",
|
|
270
|
+
)
|
|
271
|
+
if integrity.get("status") == RUN_INTEGRITY_CLEAN:
|
|
272
|
+
return updated
|
|
273
|
+
integrity.update({
|
|
274
|
+
"status": RUN_INTEGRITY_CONTAMINATED_REPAIRED,
|
|
275
|
+
"reference_eligible": False,
|
|
276
|
+
"clean_single_shot": False,
|
|
277
|
+
})
|
|
278
|
+
updated["run_integrity"] = integrity
|
|
279
|
+
return updated
|
|
280
|
+
|
|
281
|
+
|
|
282
|
+
def contaminate_run_integrity_with_event_flag(
|
|
283
|
+
workflow: dict[str, Any],
|
|
284
|
+
*,
|
|
285
|
+
reason_code: str,
|
|
286
|
+
message: str,
|
|
287
|
+
created_at: str,
|
|
288
|
+
event_type: str | None = None,
|
|
289
|
+
stage_id: str | None = None,
|
|
290
|
+
artifact_id: str | None = None,
|
|
291
|
+
metadata: dict[str, Any] | None = None,
|
|
292
|
+
) -> tuple[dict[str, Any], bool]:
|
|
293
|
+
"""Mark a workflow contaminated and report whether a new reason was added."""
|
|
294
|
+
|
|
295
|
+
updated = workflow_with_persistable_run_integrity(workflow, path="workflow_state.run_integrity")
|
|
296
|
+
integrity = require_persistable(
|
|
297
|
+
interpret_run_integrity(updated.get("run_integrity"), field_present=True),
|
|
298
|
+
path="workflow_state.run_integrity",
|
|
299
|
+
)
|
|
300
|
+
reason: dict[str, Any] = {
|
|
301
|
+
"reason_code": reason_code,
|
|
302
|
+
"message": message,
|
|
303
|
+
"created_at": created_at,
|
|
304
|
+
}
|
|
305
|
+
if event_type:
|
|
306
|
+
reason["event_type"] = event_type
|
|
307
|
+
if stage_id:
|
|
308
|
+
reason["stage_id"] = stage_id
|
|
309
|
+
if artifact_id:
|
|
310
|
+
reason["artifact_id"] = artifact_id
|
|
311
|
+
if metadata:
|
|
312
|
+
reason["metadata"] = metadata
|
|
313
|
+
existing = integrity.get("reasons") if isinstance(integrity.get("reasons"), list) else []
|
|
314
|
+
already_present = any(
|
|
315
|
+
isinstance(item, dict)
|
|
316
|
+
and item.get("reason_code") == reason_code
|
|
317
|
+
and item.get("message") == message
|
|
318
|
+
and item.get("stage_id") == stage_id
|
|
319
|
+
and item.get("artifact_id") == artifact_id
|
|
320
|
+
for item in existing
|
|
321
|
+
)
|
|
322
|
+
if already_present:
|
|
323
|
+
return workflow, False
|
|
324
|
+
integrity.update({
|
|
325
|
+
"status": RUN_INTEGRITY_CONTAMINATED,
|
|
326
|
+
"reference_eligible": False,
|
|
327
|
+
"clean_single_shot": False,
|
|
328
|
+
"reasons": [*existing, reason],
|
|
329
|
+
})
|
|
330
|
+
updated["run_integrity"] = integrity
|
|
331
|
+
updated["updated_at"] = created_at
|
|
332
|
+
return updated, True
|
|
333
|
+
|
|
334
|
+
|
|
335
|
+
def contamination_event_metadata(reason: dict[str, Any]) -> dict[str, Any]:
|
|
336
|
+
"""Return event metadata for a run-integrity contamination reason."""
|
|
337
|
+
|
|
338
|
+
return {
|
|
339
|
+
"reason_code": reason.get("reason_code"),
|
|
340
|
+
"message": reason.get("message"),
|
|
341
|
+
"reference_eligible": False,
|
|
342
|
+
"clean_single_shot": False,
|
|
343
|
+
"stage_id": reason.get("stage_id"),
|
|
344
|
+
"artifact_id": reason.get("artifact_id"),
|
|
345
|
+
"details": reason.get("metadata") if isinstance(reason.get("metadata"), dict) else {},
|
|
346
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""Stable runtime-state facade."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from . import operations
|
|
6
|
+
from .contracts_loader import load_artifact_contracts, load_stage_specs
|
|
7
|
+
from .errors import (
|
|
8
|
+
E_ACTIVE_REPAIR_OPEN,
|
|
9
|
+
E_ASSESSMENT_TARGET_COMPLETE,
|
|
10
|
+
E_FACT_LAYER_IMPORT_INVALID,
|
|
11
|
+
E_RUNTIME_STATE_NOT_INITIALIZED,
|
|
12
|
+
E_STAGE_MISMATCH,
|
|
13
|
+
RuntimeStateError,
|
|
14
|
+
)
|
|
15
|
+
from .event_log import append_event, read_event_log_records_strict, record_handoff_written
|
|
16
|
+
from .identity import new_run_id, utc_now
|
|
17
|
+
from .manifest import RUNTIME_MANIFEST_SCHEMA
|
|
18
|
+
from .claim_ledger_freeze import freeze_claim_ledger_transaction
|
|
19
|
+
from .claim_metadata_enrichment import enrich_claim_metadata_transaction
|
|
20
|
+
from .decisions import record_decision
|
|
21
|
+
from .fact_layer import import_fact_layer_transaction
|
|
22
|
+
from .lifecycle import (
|
|
23
|
+
check_runtime_state,
|
|
24
|
+
initialize_runtime_state,
|
|
25
|
+
show_runtime_state,
|
|
26
|
+
)
|
|
27
|
+
from .paths import RUNTIME_STATE_FILES, runtime_state_paths
|
|
28
|
+
from .repair import (
|
|
29
|
+
complete_repair_transaction,
|
|
30
|
+
raise_if_active_repair_open,
|
|
31
|
+
start_repair_transaction,
|
|
32
|
+
)
|
|
33
|
+
from .stage_completion import (
|
|
34
|
+
complete_finalize_transaction,
|
|
35
|
+
complete_stage_transaction,
|
|
36
|
+
raise_if_auditable_target_complete_blocks_downstream,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
__all__ = sorted([
|
|
41
|
+
"E_ACTIVE_REPAIR_OPEN",
|
|
42
|
+
"E_ASSESSMENT_TARGET_COMPLETE",
|
|
43
|
+
"E_FACT_LAYER_IMPORT_INVALID",
|
|
44
|
+
"E_RUNTIME_STATE_NOT_INITIALIZED",
|
|
45
|
+
"E_STAGE_MISMATCH",
|
|
46
|
+
"RUNTIME_MANIFEST_SCHEMA",
|
|
47
|
+
"RUNTIME_STATE_FILES",
|
|
48
|
+
"RuntimeStateError",
|
|
49
|
+
"append_event",
|
|
50
|
+
"check_runtime_state",
|
|
51
|
+
"complete_finalize_transaction",
|
|
52
|
+
"complete_repair_transaction",
|
|
53
|
+
"complete_stage_transaction",
|
|
54
|
+
"enrich_claim_metadata_transaction",
|
|
55
|
+
"freeze_claim_ledger_transaction",
|
|
56
|
+
"import_fact_layer_transaction",
|
|
57
|
+
"initialize_runtime_state",
|
|
58
|
+
"load_artifact_contracts",
|
|
59
|
+
"load_stage_specs",
|
|
60
|
+
"new_run_id",
|
|
61
|
+
"read_event_log_records_strict",
|
|
62
|
+
"record_decision",
|
|
63
|
+
"raise_if_auditable_target_complete_blocks_downstream",
|
|
64
|
+
"record_handoff_written",
|
|
65
|
+
"raise_if_active_repair_open",
|
|
66
|
+
"runtime_state_paths",
|
|
67
|
+
"show_runtime_state",
|
|
68
|
+
"start_repair_transaction",
|
|
69
|
+
"utc_now",
|
|
70
|
+
])
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Runtime-state low-level IO helpers."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import hashlib
|
|
6
|
+
import json
|
|
7
|
+
import os
|
|
8
|
+
import uuid
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
import yaml
|
|
13
|
+
|
|
14
|
+
from multi_agent_brief.orchestrator.runtime_state.errors import (
|
|
15
|
+
E_TRANSACTION_PARTIAL_WRITE,
|
|
16
|
+
RuntimeStateError,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def _read_json(path: Path) -> dict[str, Any]:
|
|
21
|
+
try:
|
|
22
|
+
data = json.loads(path.read_text(encoding="utf-8"))
|
|
23
|
+
except json.JSONDecodeError as exc:
|
|
24
|
+
raise RuntimeStateError(
|
|
25
|
+
f"Invalid JSON state file: {path}",
|
|
26
|
+
details={"path": str(path), "reason": str(exc)},
|
|
27
|
+
) from exc
|
|
28
|
+
except OSError as exc:
|
|
29
|
+
raise RuntimeStateError(
|
|
30
|
+
f"Failed to read state file: {path}",
|
|
31
|
+
details={"path": str(path), "reason": str(exc)},
|
|
32
|
+
) from exc
|
|
33
|
+
if not isinstance(data, dict):
|
|
34
|
+
raise RuntimeStateError(
|
|
35
|
+
f"State file must contain a JSON object: {path}",
|
|
36
|
+
details={"path": str(path)},
|
|
37
|
+
)
|
|
38
|
+
return data
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _read_json_if_exists(path: Path) -> dict[str, Any] | None:
|
|
42
|
+
if not path.exists():
|
|
43
|
+
return None
|
|
44
|
+
return _read_json(path)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _write_json_atomic(path: Path, payload: dict[str, Any]) -> None:
|
|
48
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
49
|
+
text = json.dumps(payload, ensure_ascii=False, indent=2, sort_keys=True)
|
|
50
|
+
text += "\n"
|
|
51
|
+
tmp = path.with_name(f".{path.name}.{uuid.uuid4().hex}.tmp")
|
|
52
|
+
try:
|
|
53
|
+
tmp.write_text(text, encoding="utf-8")
|
|
54
|
+
os.replace(tmp, path)
|
|
55
|
+
except OSError as exc:
|
|
56
|
+
try:
|
|
57
|
+
tmp.unlink(missing_ok=True)
|
|
58
|
+
except OSError:
|
|
59
|
+
pass
|
|
60
|
+
raise RuntimeStateError(
|
|
61
|
+
f"Failed to write state file: {path}",
|
|
62
|
+
details={"path": str(path), "reason": str(exc)},
|
|
63
|
+
) from exc
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def _read_state_bytes(path: Path) -> bytes | None:
|
|
67
|
+
try:
|
|
68
|
+
if not path.exists():
|
|
69
|
+
return None
|
|
70
|
+
return path.read_bytes()
|
|
71
|
+
except OSError as exc:
|
|
72
|
+
raise RuntimeStateError(
|
|
73
|
+
f"Failed to snapshot state file: {path}",
|
|
74
|
+
details={"path": str(path), "reason": str(exc)},
|
|
75
|
+
) from exc
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _restore_state_bytes(path: Path, data: bytes | None) -> None:
|
|
79
|
+
try:
|
|
80
|
+
if data is None:
|
|
81
|
+
path.unlink(missing_ok=True)
|
|
82
|
+
return
|
|
83
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
84
|
+
tmp = path.with_name(f".{path.name}.{uuid.uuid4().hex}.rollback.tmp")
|
|
85
|
+
tmp.write_bytes(data)
|
|
86
|
+
os.replace(tmp, path)
|
|
87
|
+
except OSError as exc:
|
|
88
|
+
raise RuntimeStateError(
|
|
89
|
+
f"Failed to restore state file after partial write: {path}",
|
|
90
|
+
details={"path": str(path), "reason": str(exc)},
|
|
91
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
92
|
+
) from exc
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _snapshot_state_files(paths: dict[str, Path], keys: tuple[str, ...]) -> dict[str, bytes | None]:
|
|
96
|
+
return {key: _read_state_bytes(paths[key]) for key in keys}
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def _restore_state_files(paths: dict[str, Path], snapshots: dict[str, bytes | None]) -> None:
|
|
100
|
+
rollback_errors: list[dict[str, str]] = []
|
|
101
|
+
for key, data in snapshots.items():
|
|
102
|
+
try:
|
|
103
|
+
_restore_state_bytes(paths[key], data)
|
|
104
|
+
except RuntimeStateError as exc:
|
|
105
|
+
rollback_errors.append({
|
|
106
|
+
"key": key,
|
|
107
|
+
"path": str(paths[key]),
|
|
108
|
+
"reason": str(exc),
|
|
109
|
+
})
|
|
110
|
+
if rollback_errors:
|
|
111
|
+
raise RuntimeStateError(
|
|
112
|
+
"Runtime state rollback failed after partial write.",
|
|
113
|
+
details={"rollback_errors": rollback_errors},
|
|
114
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
def _append_jsonl(path: Path, payload: dict[str, Any]) -> None:
|
|
119
|
+
path.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
line = json.dumps(payload, ensure_ascii=False, sort_keys=True) + "\n"
|
|
121
|
+
try:
|
|
122
|
+
with path.open("a", encoding="utf-8") as fh:
|
|
123
|
+
fh.write(line)
|
|
124
|
+
except OSError as exc:
|
|
125
|
+
raise RuntimeStateError(
|
|
126
|
+
f"Failed to append event log: {path}",
|
|
127
|
+
details={"path": str(path), "reason": str(exc)},
|
|
128
|
+
) from exc
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _sha256_file(path: Path) -> str:
|
|
132
|
+
digest = hashlib.sha256()
|
|
133
|
+
with path.open("rb") as fh:
|
|
134
|
+
for chunk in iter(lambda: fh.read(1024 * 1024), b""):
|
|
135
|
+
digest.update(chunk)
|
|
136
|
+
return digest.hexdigest()
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
def _load_yaml(path: Path) -> dict[str, Any]:
|
|
140
|
+
try:
|
|
141
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8"))
|
|
142
|
+
except yaml.YAMLError as exc:
|
|
143
|
+
raise RuntimeStateError(
|
|
144
|
+
f"Invalid YAML contract file: {path}",
|
|
145
|
+
details={"path": str(path), "reason": str(exc)},
|
|
146
|
+
) from exc
|
|
147
|
+
except OSError as exc:
|
|
148
|
+
raise RuntimeStateError(
|
|
149
|
+
f"Failed to read contract file: {path}",
|
|
150
|
+
details={"path": str(path), "reason": str(exc)},
|
|
151
|
+
) from exc
|
|
152
|
+
if not isinstance(data, dict):
|
|
153
|
+
raise RuntimeStateError(
|
|
154
|
+
f"Contract file must contain a mapping: {path}",
|
|
155
|
+
details={"path": str(path)},
|
|
156
|
+
)
|
|
157
|
+
return data
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
def _load_workspace_yaml(path: Path) -> dict[str, Any]:
|
|
161
|
+
if not path.exists():
|
|
162
|
+
return {}
|
|
163
|
+
try:
|
|
164
|
+
data = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
|
|
165
|
+
except (OSError, yaml.YAMLError):
|
|
166
|
+
return {}
|
|
167
|
+
return data if isinstance(data, dict) else {}
|