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,200 @@
|
|
|
1
|
+
"""Trajectory Regulation decision-narrowing for workflow state.
|
|
2
|
+
|
|
3
|
+
Deterministically narrows next_allowed_decisions after retry/repair/blocker
|
|
4
|
+
budgets are exhausted. Control-state projection only; executes no repair.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
from pathlib import Path
|
|
10
|
+
from typing import Any
|
|
11
|
+
|
|
12
|
+
from multi_agent_brief.product.trajectory_regulation import project_workspace_trajectory_regulation
|
|
13
|
+
from multi_agent_brief.orchestrator.runtime_state.completion_gates import _raise_completion_reasons
|
|
14
|
+
from multi_agent_brief.orchestrator.runtime_state.errors import (
|
|
15
|
+
E_ILLEGAL_TRANSITION,
|
|
16
|
+
RuntimeStateError,
|
|
17
|
+
)
|
|
18
|
+
from multi_agent_brief.orchestrator.runtime_state.workflow import (
|
|
19
|
+
STAGE_READY,
|
|
20
|
+
_allowed_decisions_for_stage,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
TRAJECTORY_DECISION_NARROWING_STATUS = "decision_narrowed"
|
|
25
|
+
TRAJECTORY_NARROWED_DECISIONS = ["request_human_review", "block_run"]
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def _trajectory_decision_narrowing(
|
|
29
|
+
*,
|
|
30
|
+
workspace: Path,
|
|
31
|
+
workflow: dict[str, Any],
|
|
32
|
+
event_records: list[dict[str, Any]],
|
|
33
|
+
run_id: str,
|
|
34
|
+
stage_id: str | None = None,
|
|
35
|
+
assume_stage_ready: bool = False,
|
|
36
|
+
) -> dict[str, Any] | None:
|
|
37
|
+
current_stage = str(stage_id or workflow.get("current_stage") or "")
|
|
38
|
+
if not current_stage:
|
|
39
|
+
return None
|
|
40
|
+
projection_workflow = workflow
|
|
41
|
+
if stage_id or assume_stage_ready:
|
|
42
|
+
projection_workflow = dict(workflow)
|
|
43
|
+
projection_workflow["current_stage"] = current_stage
|
|
44
|
+
if assume_stage_ready:
|
|
45
|
+
statuses = dict(projection_workflow.get("stage_statuses") or {})
|
|
46
|
+
entry = statuses.get(current_stage) if isinstance(statuses.get(current_stage), dict) else {}
|
|
47
|
+
entry = dict(entry)
|
|
48
|
+
entry["status"] = STAGE_READY
|
|
49
|
+
statuses[current_stage] = entry
|
|
50
|
+
projection_workflow["stage_statuses"] = statuses
|
|
51
|
+
projection = project_workspace_trajectory_regulation(
|
|
52
|
+
workspace,
|
|
53
|
+
workflow_state=projection_workflow,
|
|
54
|
+
event_records=event_records,
|
|
55
|
+
event_log_present=True,
|
|
56
|
+
event_log_corrupt_count=0,
|
|
57
|
+
run_id=run_id,
|
|
58
|
+
)
|
|
59
|
+
if projection.get("status") != "action_required":
|
|
60
|
+
return None
|
|
61
|
+
actions = projection.get("recommended_actions") if isinstance(projection.get("recommended_actions"), list) else []
|
|
62
|
+
relevant_actions: list[dict[str, str]] = []
|
|
63
|
+
reasons: list[str] = []
|
|
64
|
+
for action in actions:
|
|
65
|
+
if not isinstance(action, dict):
|
|
66
|
+
continue
|
|
67
|
+
decision = str(action.get("action") or "")
|
|
68
|
+
stage_id = str(action.get("stage_id") or "")
|
|
69
|
+
if stage_id != current_stage or decision not in TRAJECTORY_NARROWED_DECISIONS:
|
|
70
|
+
continue
|
|
71
|
+
reason = str(action.get("reason") or "trajectory_budget_exceeded")
|
|
72
|
+
relevant_actions.append({
|
|
73
|
+
"action": decision,
|
|
74
|
+
"stage_id": stage_id,
|
|
75
|
+
"reason": reason,
|
|
76
|
+
})
|
|
77
|
+
if reason not in reasons:
|
|
78
|
+
reasons.append(reason)
|
|
79
|
+
if not relevant_actions:
|
|
80
|
+
return None
|
|
81
|
+
return {
|
|
82
|
+
"status": TRAJECTORY_DECISION_NARROWING_STATUS,
|
|
83
|
+
"stage_id": current_stage,
|
|
84
|
+
"reasons": reasons or ["trajectory_budget_exceeded"],
|
|
85
|
+
"allowed_decisions": list(TRAJECTORY_NARROWED_DECISIONS),
|
|
86
|
+
"recommended_actions": relevant_actions,
|
|
87
|
+
"runtime_effect": "decision_narrowing",
|
|
88
|
+
"source": "trajectory_regulation",
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def _raise_if_trajectory_narrows_repair_route(
|
|
93
|
+
*,
|
|
94
|
+
workspace: Path,
|
|
95
|
+
workflow: dict[str, Any],
|
|
96
|
+
event_records: list[dict[str, Any]],
|
|
97
|
+
run_id: str,
|
|
98
|
+
route: dict[str, Any],
|
|
99
|
+
) -> None:
|
|
100
|
+
repair_owner = str(route.get("repair_owner") or "")
|
|
101
|
+
if not repair_owner:
|
|
102
|
+
return
|
|
103
|
+
narrowing = _trajectory_decision_narrowing(
|
|
104
|
+
workspace=workspace,
|
|
105
|
+
workflow=workflow,
|
|
106
|
+
event_records=event_records,
|
|
107
|
+
run_id=run_id,
|
|
108
|
+
stage_id=repair_owner,
|
|
109
|
+
assume_stage_ready=True,
|
|
110
|
+
)
|
|
111
|
+
if not narrowing:
|
|
112
|
+
return
|
|
113
|
+
raise RuntimeStateError(
|
|
114
|
+
"Repair start is blocked because trajectory regulation narrowed the selected repair route.",
|
|
115
|
+
details={
|
|
116
|
+
"stage_id": repair_owner,
|
|
117
|
+
"decision": "delegate_repair",
|
|
118
|
+
"allowed_decisions": list(TRAJECTORY_NARROWED_DECISIONS),
|
|
119
|
+
"trajectory_regulation": narrowing,
|
|
120
|
+
"selected_route": {
|
|
121
|
+
"repair_owner": route.get("repair_owner"),
|
|
122
|
+
"source": route.get("source") or {},
|
|
123
|
+
"recommended_action": route.get("recommended_action"),
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
error_code=E_ILLEGAL_TRANSITION,
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def _workflow_with_trajectory_decision_narrowing(
|
|
131
|
+
*,
|
|
132
|
+
workspace: Path,
|
|
133
|
+
workflow: dict[str, Any],
|
|
134
|
+
stages: list[dict[str, Any]],
|
|
135
|
+
event_records: list[dict[str, Any]],
|
|
136
|
+
run_id: str,
|
|
137
|
+
) -> dict[str, Any]:
|
|
138
|
+
updated = dict(workflow)
|
|
139
|
+
updated.pop("trajectory_regulation", None)
|
|
140
|
+
narrowing = _trajectory_decision_narrowing(
|
|
141
|
+
workspace=workspace,
|
|
142
|
+
workflow=updated,
|
|
143
|
+
event_records=event_records,
|
|
144
|
+
run_id=run_id,
|
|
145
|
+
)
|
|
146
|
+
if narrowing:
|
|
147
|
+
updated["trajectory_regulation"] = narrowing
|
|
148
|
+
updated["next_allowed_decisions"] = list(TRAJECTORY_NARROWED_DECISIONS)
|
|
149
|
+
else:
|
|
150
|
+
updated["next_allowed_decisions"] = _allowed_decisions_for_stage(
|
|
151
|
+
stages,
|
|
152
|
+
str(updated.get("current_stage") or "") or None,
|
|
153
|
+
)
|
|
154
|
+
return updated
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def _trajectory_narrowing_changed(old_workflow: dict[str, Any], workflow: dict[str, Any]) -> bool:
|
|
158
|
+
return old_workflow.get("trajectory_regulation") != workflow.get("trajectory_regulation")
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
def _raise_if_trajectory_narrows_success_path(
|
|
162
|
+
*,
|
|
163
|
+
workspace: Path,
|
|
164
|
+
workflow: dict[str, Any],
|
|
165
|
+
event_records: list[dict[str, Any]],
|
|
166
|
+
run_id: str,
|
|
167
|
+
stage_id: str,
|
|
168
|
+
decision: str,
|
|
169
|
+
) -> None:
|
|
170
|
+
narrowing = _trajectory_decision_narrowing(
|
|
171
|
+
workspace=workspace,
|
|
172
|
+
workflow=workflow,
|
|
173
|
+
event_records=event_records,
|
|
174
|
+
run_id=run_id,
|
|
175
|
+
)
|
|
176
|
+
if not narrowing:
|
|
177
|
+
return
|
|
178
|
+
if str(narrowing.get("stage_id") or "") != stage_id:
|
|
179
|
+
return
|
|
180
|
+
allowed = [str(item) for item in narrowing.get("allowed_decisions") or []]
|
|
181
|
+
if decision in allowed:
|
|
182
|
+
return
|
|
183
|
+
reasons = [
|
|
184
|
+
(
|
|
185
|
+
"Trajectory regulation narrowed current-stage decisions to "
|
|
186
|
+
f"{', '.join(allowed) or ', '.join(TRAJECTORY_NARROWED_DECISIONS)}; "
|
|
187
|
+
f"decision '{decision}' is not allowed."
|
|
188
|
+
)
|
|
189
|
+
]
|
|
190
|
+
_raise_completion_reasons(
|
|
191
|
+
message=f"Cannot complete stage '{stage_id}' because trajectory regulation narrowed decisions",
|
|
192
|
+
reasons=reasons,
|
|
193
|
+
error_code=E_ILLEGAL_TRANSITION,
|
|
194
|
+
details={
|
|
195
|
+
"stage_id": stage_id,
|
|
196
|
+
"decision": decision,
|
|
197
|
+
"allowed_decisions": allowed or list(TRAJECTORY_NARROWED_DECISIONS),
|
|
198
|
+
"trajectory_regulation": narrowing,
|
|
199
|
+
},
|
|
200
|
+
)
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
"""Workflow state helpers for Orchestrator runtime state."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import Any
|
|
8
|
+
|
|
9
|
+
from multi_agent_brief.orchestrator.run_integrity import interpret_run_integrity, require_persistable
|
|
10
|
+
from multi_agent_brief.orchestrator.runtime_state.contracts_loader import _stage_ids
|
|
11
|
+
from multi_agent_brief.orchestrator.runtime_state.errors import E_TRANSACTION_INTEGRITY, RuntimeStateError
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
WORKFLOW_STATE_SCHEMA = "multi-agent-brief-workflow-state/v1"
|
|
15
|
+
|
|
16
|
+
STAGE_PENDING = "pending"
|
|
17
|
+
STAGE_READY = "ready"
|
|
18
|
+
STAGE_COMPLETE = "complete"
|
|
19
|
+
STAGE_BLOCKED = "blocked"
|
|
20
|
+
STAGE_SKIPPED = "skipped"
|
|
21
|
+
PERSISTED_STAGE_STATUSES = {STAGE_PENDING, STAGE_READY, STAGE_COMPLETE, STAGE_BLOCKED, STAGE_SKIPPED}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
@dataclass(frozen=True)
|
|
25
|
+
class StageCompletionVerdict:
|
|
26
|
+
"""Single interpretation of one persisted stage status."""
|
|
27
|
+
|
|
28
|
+
kind: str
|
|
29
|
+
value: dict[str, Any]
|
|
30
|
+
reasons: tuple[str, ...] = ()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _workflow_is_finalized(workflow: dict[str, Any] | None) -> bool:
|
|
34
|
+
if not workflow:
|
|
35
|
+
return False
|
|
36
|
+
finalize = project_stage_completion_for_read(
|
|
37
|
+
interpret_stage_completion(workflow, "finalize")
|
|
38
|
+
)
|
|
39
|
+
return workflow.get("current_stage") is None and finalize.get("complete") is True
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def _initial_stage_statuses(stages: list[dict[str, Any]], *, now: str) -> dict[str, dict[str, Any]]:
|
|
43
|
+
statuses: dict[str, dict[str, Any]] = {}
|
|
44
|
+
first = True
|
|
45
|
+
for stage_id in _stage_ids(stages):
|
|
46
|
+
statuses[stage_id] = {
|
|
47
|
+
"status": STAGE_READY if first else STAGE_PENDING,
|
|
48
|
+
"reason": "",
|
|
49
|
+
"updated_at": now,
|
|
50
|
+
}
|
|
51
|
+
first = False
|
|
52
|
+
return statuses
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def _initial_workflow_state(
|
|
56
|
+
*,
|
|
57
|
+
run_id: str,
|
|
58
|
+
stages: list[dict[str, Any]],
|
|
59
|
+
created_at: str,
|
|
60
|
+
updated_at: str,
|
|
61
|
+
) -> dict[str, Any]:
|
|
62
|
+
stage_statuses = _initial_stage_statuses(stages, now=updated_at)
|
|
63
|
+
current_stage = _stage_ids(stages)[0] if stages else None
|
|
64
|
+
return {
|
|
65
|
+
"schema_version": WORKFLOW_STATE_SCHEMA,
|
|
66
|
+
"run_id": run_id,
|
|
67
|
+
"created_at": created_at,
|
|
68
|
+
"updated_at": updated_at,
|
|
69
|
+
"current_stage": current_stage,
|
|
70
|
+
"blocked": False,
|
|
71
|
+
"blocking_reason": "",
|
|
72
|
+
"stage_statuses": stage_statuses,
|
|
73
|
+
"last_decision": None,
|
|
74
|
+
"next_allowed_decisions": _allowed_decisions_for_stage(stages, current_stage),
|
|
75
|
+
"run_integrity": require_persistable(
|
|
76
|
+
interpret_run_integrity(None, field_present=False),
|
|
77
|
+
path="workflow_state.run_integrity",
|
|
78
|
+
),
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def _allowed_decisions_for_stage(
|
|
83
|
+
stages: list[dict[str, Any]],
|
|
84
|
+
stage_id: str | None,
|
|
85
|
+
) -> list[str]:
|
|
86
|
+
if stage_id is None:
|
|
87
|
+
return []
|
|
88
|
+
for stage in stages:
|
|
89
|
+
if stage.get("stage_id") == stage_id:
|
|
90
|
+
decisions = stage.get("allowed_decisions") or []
|
|
91
|
+
return [str(decision) for decision in decisions]
|
|
92
|
+
return []
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _current_stage_index(stages: list[dict[str, Any]], stage_id: str | None) -> int | None:
|
|
96
|
+
ids = _stage_ids(stages)
|
|
97
|
+
if stage_id in ids:
|
|
98
|
+
return ids.index(str(stage_id))
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _next_stage_id(stages: list[dict[str, Any]], stage_id: str) -> str | None:
|
|
103
|
+
ids = _stage_ids(stages)
|
|
104
|
+
if stage_id not in ids:
|
|
105
|
+
return None
|
|
106
|
+
idx = ids.index(stage_id)
|
|
107
|
+
if idx + 1 >= len(ids):
|
|
108
|
+
return None
|
|
109
|
+
return ids[idx + 1]
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def _stage_status(workflow: dict[str, Any], stage_id: str) -> str:
|
|
113
|
+
projection = project_stage_completion_for_read(interpret_stage_completion(workflow, stage_id))
|
|
114
|
+
return str(projection.get("status") or STAGE_PENDING)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def _stage_is_complete_or_skipped(workflow: dict[str, Any], stage_id: str) -> bool:
|
|
118
|
+
projection = project_stage_completion_for_read(interpret_stage_completion(workflow, stage_id))
|
|
119
|
+
return bool(projection.get("complete_or_skipped"))
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def interpret_stage_completion(workflow: Any, stage_id: str) -> StageCompletionVerdict:
|
|
123
|
+
"""Interpret one stage status once for read and write adapters."""
|
|
124
|
+
|
|
125
|
+
stage_label = stage_id or "<missing>"
|
|
126
|
+
if not isinstance(workflow, dict):
|
|
127
|
+
return _degraded_stage_completion(stage_label, "workflow_state.json must be an object.")
|
|
128
|
+
statuses = workflow.get("stage_statuses")
|
|
129
|
+
if not isinstance(statuses, dict):
|
|
130
|
+
return _degraded_stage_completion(stage_label, "workflow_state.stage_statuses must be an object.")
|
|
131
|
+
if stage_id not in statuses:
|
|
132
|
+
return _degraded_stage_completion(stage_label, f"workflow_state.stage_statuses.{stage_label} is missing.")
|
|
133
|
+
entry = statuses.get(stage_id)
|
|
134
|
+
if not isinstance(entry, dict):
|
|
135
|
+
return _degraded_stage_completion(stage_label, f"workflow_state.stage_statuses.{stage_label} must be an object.")
|
|
136
|
+
raw_status = entry.get("status")
|
|
137
|
+
if not isinstance(raw_status, str) or not raw_status.strip():
|
|
138
|
+
return _degraded_stage_completion(stage_label, f"workflow_state.stage_statuses.{stage_label}.status is required.")
|
|
139
|
+
status = raw_status.strip()
|
|
140
|
+
if status not in PERSISTED_STAGE_STATUSES:
|
|
141
|
+
return _degraded_stage_completion(
|
|
142
|
+
stage_label,
|
|
143
|
+
f"workflow_state.stage_statuses.{stage_label}.status is invalid: {status}.",
|
|
144
|
+
)
|
|
145
|
+
return StageCompletionVerdict(
|
|
146
|
+
kind="canonical",
|
|
147
|
+
value=_stage_completion_projection(stage_label, status=status),
|
|
148
|
+
)
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def project_stage_completion_for_read(verdict: StageCompletionVerdict) -> dict[str, Any]:
|
|
152
|
+
"""Return the read-side projection for a stage-completion verdict."""
|
|
153
|
+
|
|
154
|
+
return dict(verdict.value)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def require_stage_completion_persistable(
|
|
158
|
+
verdict: StageCompletionVerdict,
|
|
159
|
+
*,
|
|
160
|
+
path: str | Path,
|
|
161
|
+
) -> dict[str, Any]:
|
|
162
|
+
"""Return canonical stage-completion projection or fail closed."""
|
|
163
|
+
|
|
164
|
+
if verdict.kind != "canonical":
|
|
165
|
+
raise RuntimeStateError(
|
|
166
|
+
"workflow_state.stage_statuses is malformed.",
|
|
167
|
+
details={"path": str(path), "reasons": list(verdict.reasons)},
|
|
168
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
169
|
+
)
|
|
170
|
+
return dict(verdict.value)
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def workflow_with_persistable_stage_completions(
|
|
174
|
+
workflow: dict[str, Any],
|
|
175
|
+
*,
|
|
176
|
+
stages: list[dict[str, Any]],
|
|
177
|
+
path: str | Path,
|
|
178
|
+
) -> dict[str, Any]:
|
|
179
|
+
"""Return a shallow workflow copy after validating persisted stage statuses."""
|
|
180
|
+
|
|
181
|
+
if not isinstance(workflow.get("stage_statuses"), dict):
|
|
182
|
+
raise RuntimeStateError(
|
|
183
|
+
"workflow_state.stage_statuses is malformed.",
|
|
184
|
+
details={"path": str(path), "reason": "workflow_state.stage_statuses must be an object."},
|
|
185
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
186
|
+
)
|
|
187
|
+
stage_ids = _stage_ids(stages)
|
|
188
|
+
current_stage = workflow.get("current_stage")
|
|
189
|
+
if current_stage is not None and str(current_stage) not in stage_ids:
|
|
190
|
+
raise RuntimeStateError(
|
|
191
|
+
"workflow_state.current_stage is invalid.",
|
|
192
|
+
details={"path": str(path), "current_stage": current_stage},
|
|
193
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
194
|
+
)
|
|
195
|
+
for stage_id in stage_ids:
|
|
196
|
+
require_stage_completion_persistable(
|
|
197
|
+
interpret_stage_completion(workflow, stage_id),
|
|
198
|
+
path=f"{path}.stage_statuses.{stage_id}",
|
|
199
|
+
)
|
|
200
|
+
if current_stage is None:
|
|
201
|
+
finalize = project_stage_completion_for_read(interpret_stage_completion(workflow, "finalize"))
|
|
202
|
+
if finalize.get("complete") is not True:
|
|
203
|
+
raise RuntimeStateError(
|
|
204
|
+
"workflow_state.current_stage is null but finalize is not complete.",
|
|
205
|
+
details={"path": str(path), "finalize_status": finalize.get("status")},
|
|
206
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
207
|
+
)
|
|
208
|
+
return dict(workflow)
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _stage_completion_projection(stage_id: str, *, status: str) -> dict[str, Any]:
|
|
212
|
+
return {
|
|
213
|
+
"stage_id": stage_id,
|
|
214
|
+
"status": status,
|
|
215
|
+
"complete": status == STAGE_COMPLETE,
|
|
216
|
+
"skipped": status == STAGE_SKIPPED,
|
|
217
|
+
"complete_or_skipped": status in {STAGE_COMPLETE, STAGE_SKIPPED},
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
def _degraded_stage_completion(stage_id: str, reason: str) -> StageCompletionVerdict:
|
|
222
|
+
return StageCompletionVerdict(
|
|
223
|
+
kind="degraded",
|
|
224
|
+
value=_stage_completion_projection(stage_id, status=STAGE_PENDING),
|
|
225
|
+
reasons=(reason,),
|
|
226
|
+
)
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
def _stage_entry(workflow: dict[str, Any], stage_id: str | None) -> dict[str, Any]:
|
|
230
|
+
if stage_id is None:
|
|
231
|
+
return {}
|
|
232
|
+
return ((workflow.get("stage_statuses") or {}).get(stage_id) or {})
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def _changed_workflow_events(
|
|
236
|
+
*,
|
|
237
|
+
old_workflow: dict[str, Any],
|
|
238
|
+
workflow: dict[str, Any],
|
|
239
|
+
) -> list[dict[str, Any]]:
|
|
240
|
+
events: list[dict[str, Any]] = []
|
|
241
|
+
current_stage = workflow.get("current_stage")
|
|
242
|
+
old_current_stage = old_workflow.get("current_stage")
|
|
243
|
+
old_entry = _stage_entry(old_workflow, str(current_stage) if current_stage else None)
|
|
244
|
+
new_entry = _stage_entry(workflow, str(current_stage) if current_stage else None)
|
|
245
|
+
stage_changed = (
|
|
246
|
+
current_stage != old_current_stage
|
|
247
|
+
or old_entry.get("status") != new_entry.get("status")
|
|
248
|
+
or old_entry.get("reason") != new_entry.get("reason")
|
|
249
|
+
)
|
|
250
|
+
if current_stage and stage_changed:
|
|
251
|
+
events.append({
|
|
252
|
+
"event_type": "stage_status_changed",
|
|
253
|
+
"stage_id": str(current_stage),
|
|
254
|
+
"reason": str(workflow.get("blocking_reason") or ""),
|
|
255
|
+
"metadata": {"status": new_entry.get("status")},
|
|
256
|
+
})
|
|
257
|
+
|
|
258
|
+
run_block_changed = (
|
|
259
|
+
bool(workflow.get("blocked")) is True
|
|
260
|
+
and (
|
|
261
|
+
bool(old_workflow.get("blocked")) is not True
|
|
262
|
+
or old_workflow.get("blocking_reason") != workflow.get("blocking_reason")
|
|
263
|
+
or old_current_stage != current_stage
|
|
264
|
+
)
|
|
265
|
+
)
|
|
266
|
+
if run_block_changed:
|
|
267
|
+
events.append({
|
|
268
|
+
"event_type": "run_blocked",
|
|
269
|
+
"stage_id": str(current_stage) if current_stage else None,
|
|
270
|
+
"reason": str(workflow.get("blocking_reason") or ""),
|
|
271
|
+
"metadata": {},
|
|
272
|
+
})
|
|
273
|
+
return events
|
|
274
|
+
|
|
275
|
+
|
|
276
|
+
def _required_consumed_artifacts(
|
|
277
|
+
*,
|
|
278
|
+
stage: dict[str, Any],
|
|
279
|
+
artifacts_by_id: dict[str, dict[str, Any]],
|
|
280
|
+
) -> list[str]:
|
|
281
|
+
consumed = stage.get("consumes") or []
|
|
282
|
+
required: list[str] = []
|
|
283
|
+
for item in consumed:
|
|
284
|
+
artifact_id = str(item)
|
|
285
|
+
contract = artifacts_by_id.get(artifact_id)
|
|
286
|
+
if contract and bool(contract.get("required", False)):
|
|
287
|
+
required.append(artifact_id)
|
|
288
|
+
return required
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def _status_entry(
|
|
292
|
+
status: str,
|
|
293
|
+
reason: str,
|
|
294
|
+
updated_at: str,
|
|
295
|
+
*,
|
|
296
|
+
metadata: dict[str, Any] | None = None,
|
|
297
|
+
) -> dict[str, Any]:
|
|
298
|
+
entry = {
|
|
299
|
+
"status": status,
|
|
300
|
+
"reason": reason,
|
|
301
|
+
"updated_at": updated_at,
|
|
302
|
+
}
|
|
303
|
+
if metadata:
|
|
304
|
+
entry["metadata"] = metadata
|
|
305
|
+
return entry
|
|
306
|
+
|
|
307
|
+
|
|
308
|
+
def _workflow_after_completion(
|
|
309
|
+
*,
|
|
310
|
+
workflow: dict[str, Any],
|
|
311
|
+
stages: list[dict[str, Any]],
|
|
312
|
+
stage_id: str,
|
|
313
|
+
reason: str,
|
|
314
|
+
now: str,
|
|
315
|
+
transaction_id: str,
|
|
316
|
+
finalize: bool,
|
|
317
|
+
runtime_provenance: dict[str, Any] | None = None,
|
|
318
|
+
) -> dict[str, Any]:
|
|
319
|
+
decision = "finalize" if finalize else "continue"
|
|
320
|
+
next_stage = _next_stage_id(stages, stage_id)
|
|
321
|
+
current_stage = None if finalize else next_stage
|
|
322
|
+
statuses = dict(workflow.get("stage_statuses") or {})
|
|
323
|
+
completion_metadata = {"runtime_provenance": runtime_provenance} if runtime_provenance else None
|
|
324
|
+
statuses[stage_id] = _status_entry(STAGE_COMPLETE, reason, now, metadata=completion_metadata)
|
|
325
|
+
if current_stage:
|
|
326
|
+
statuses[current_stage] = _status_entry(STAGE_READY, "", now)
|
|
327
|
+
updated = dict(workflow)
|
|
328
|
+
updated["updated_at"] = now
|
|
329
|
+
updated["current_stage"] = current_stage
|
|
330
|
+
updated["blocked"] = False
|
|
331
|
+
updated["blocking_reason"] = ""
|
|
332
|
+
updated["stage_statuses"] = statuses
|
|
333
|
+
updated["last_decision"] = {
|
|
334
|
+
"stage_id": stage_id,
|
|
335
|
+
"decision": decision,
|
|
336
|
+
"reason": reason,
|
|
337
|
+
"created_at": now,
|
|
338
|
+
}
|
|
339
|
+
updated["last_completion_transaction"] = {
|
|
340
|
+
"transaction_id": transaction_id,
|
|
341
|
+
"stage_id": stage_id,
|
|
342
|
+
"decision": decision,
|
|
343
|
+
"reason": reason,
|
|
344
|
+
"created_at": now,
|
|
345
|
+
}
|
|
346
|
+
if runtime_provenance:
|
|
347
|
+
updated["last_decision"]["runtime_provenance"] = runtime_provenance
|
|
348
|
+
updated["last_completion_transaction"]["runtime_provenance"] = runtime_provenance
|
|
349
|
+
updated["next_allowed_decisions"] = _allowed_decisions_for_stage(stages, current_stage)
|
|
350
|
+
return updated
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"""Shared durable source-evidence path rules for runtime controls."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
NON_EVIDENCE_INPUT_SUBDIRS = {"context", "feedback", "instructions"}
|
|
9
|
+
NON_EVIDENCE_INPUT_FILENAMES = {
|
|
10
|
+
".ds_store",
|
|
11
|
+
".gitkeep",
|
|
12
|
+
".keep",
|
|
13
|
+
"readme",
|
|
14
|
+
"readme.md",
|
|
15
|
+
"readme.txt",
|
|
16
|
+
}
|
|
17
|
+
NON_EVIDENCE_INPUT_FILENAME_PARTS = ("placeholder", "template")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def is_evidence_input_path(path: Path, workspace: Path) -> bool:
|
|
21
|
+
"""Return whether an input path can count as durable evidence."""
|
|
22
|
+
input_dir = (workspace / "input").resolve()
|
|
23
|
+
resolved = path.resolve()
|
|
24
|
+
try:
|
|
25
|
+
relative = resolved.relative_to(input_dir)
|
|
26
|
+
except ValueError:
|
|
27
|
+
return True
|
|
28
|
+
if relative.parts and relative.parts[0] in NON_EVIDENCE_INPUT_SUBDIRS:
|
|
29
|
+
return False
|
|
30
|
+
if any(part.startswith(".") for part in relative.parts):
|
|
31
|
+
return False
|
|
32
|
+
name = path.name.lower()
|
|
33
|
+
if name in NON_EVIDENCE_INPUT_FILENAMES:
|
|
34
|
+
return False
|
|
35
|
+
if any(part in name for part in NON_EVIDENCE_INPUT_FILENAME_PARTS):
|
|
36
|
+
return False
|
|
37
|
+
if path.is_file():
|
|
38
|
+
try:
|
|
39
|
+
if path.stat().st_size == 0:
|
|
40
|
+
return False
|
|
41
|
+
except OSError:
|
|
42
|
+
return False
|
|
43
|
+
return True
|