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,675 @@
|
|
|
1
|
+
"""Runtime-state lifecycle: initialize, show, and check.
|
|
2
|
+
|
|
3
|
+
Owns run initialization (including run-scoped control-artifact reset),
|
|
4
|
+
read-only state projection, and state consistency checking.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import uuid
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from typing import Any
|
|
13
|
+
|
|
14
|
+
from multi_agent_brief.contracts.schemas.claim_draft import ClaimDraftContract, claim_draft_diagnostics # noqa: F401
|
|
15
|
+
from multi_agent_brief.feedback.feedback_contract import current_stage_feedback_blocking_reasons
|
|
16
|
+
from multi_agent_brief.orchestrator.fact_layer_import import summarize_fact_layer_import
|
|
17
|
+
from multi_agent_brief.orchestrator.runtime_state._io import (
|
|
18
|
+
_read_json,
|
|
19
|
+
_read_json_if_exists,
|
|
20
|
+
_read_state_bytes,
|
|
21
|
+
_restore_state_bytes,
|
|
22
|
+
_restore_state_files,
|
|
23
|
+
_snapshot_state_files,
|
|
24
|
+
_write_json_atomic,
|
|
25
|
+
)
|
|
26
|
+
from multi_agent_brief.orchestrator.runtime_state._transactions import (
|
|
27
|
+
_archive_finalized_state_if_needed,
|
|
28
|
+
_completion_transaction_integrity_reason,
|
|
29
|
+
_load_manifest_and_workflow,
|
|
30
|
+
_persist_run_contamination,
|
|
31
|
+
)
|
|
32
|
+
from multi_agent_brief.orchestrator.runtime_state.artifact_registry import (
|
|
33
|
+
ARTIFACT_EXPECTED,
|
|
34
|
+
ARTIFACT_INVALID,
|
|
35
|
+
ARTIFACT_VALID,
|
|
36
|
+
_build_artifact_registry,
|
|
37
|
+
_changed_artifact_events,
|
|
38
|
+
interpret_frozen_artifact_integrity,
|
|
39
|
+
require_frozen_artifact_integrity_pass,
|
|
40
|
+
)
|
|
41
|
+
from multi_agent_brief.orchestrator.runtime_state.completion_gates import _raise_completion_reasons
|
|
42
|
+
from multi_agent_brief.orchestrator.runtime_state.contracts_loader import (
|
|
43
|
+
_artifact_map,
|
|
44
|
+
load_artifact_contracts,
|
|
45
|
+
load_stage_specs,
|
|
46
|
+
)
|
|
47
|
+
from multi_agent_brief.orchestrator.runtime_state.errors import (
|
|
48
|
+
E_TRANSACTION_INTEGRITY,
|
|
49
|
+
E_TRANSACTION_PARTIAL_WRITE,
|
|
50
|
+
RuntimeStateError,
|
|
51
|
+
)
|
|
52
|
+
from multi_agent_brief.orchestrator.runtime_state.event_log import (
|
|
53
|
+
_read_event_log_records,
|
|
54
|
+
append_event,
|
|
55
|
+
)
|
|
56
|
+
from multi_agent_brief.orchestrator.runtime_state.identity import (
|
|
57
|
+
_safe_previous_run_id,
|
|
58
|
+
_validate_runtime_run_id,
|
|
59
|
+
new_run_id,
|
|
60
|
+
utc_now,
|
|
61
|
+
)
|
|
62
|
+
from multi_agent_brief.orchestrator.runtime_state.manifest import (
|
|
63
|
+
PRESERVED_RUNTIME_MANIFEST_EXTENSION_KEYS,
|
|
64
|
+
RUNTIME_MANIFEST_SCHEMA,
|
|
65
|
+
_runtime_manifest,
|
|
66
|
+
)
|
|
67
|
+
from multi_agent_brief.orchestrator.runtime_state.paths import (
|
|
68
|
+
RUNTIME_STATE_FILES,
|
|
69
|
+
_require_workspace,
|
|
70
|
+
_workspace_relative,
|
|
71
|
+
runtime_state_paths,
|
|
72
|
+
)
|
|
73
|
+
from multi_agent_brief.orchestrator.runtime_state.trajectory import (
|
|
74
|
+
TRAJECTORY_DECISION_NARROWING_STATUS,
|
|
75
|
+
_trajectory_narrowing_changed,
|
|
76
|
+
_workflow_with_trajectory_decision_narrowing,
|
|
77
|
+
)
|
|
78
|
+
from multi_agent_brief.orchestrator.runtime_state.workflow import (
|
|
79
|
+
STAGE_BLOCKED,
|
|
80
|
+
STAGE_COMPLETE,
|
|
81
|
+
STAGE_PENDING,
|
|
82
|
+
STAGE_READY,
|
|
83
|
+
STAGE_SKIPPED,
|
|
84
|
+
WORKFLOW_STATE_SCHEMA,
|
|
85
|
+
_allowed_decisions_for_stage,
|
|
86
|
+
_changed_workflow_events,
|
|
87
|
+
_initial_workflow_state,
|
|
88
|
+
_required_consumed_artifacts,
|
|
89
|
+
_status_entry,
|
|
90
|
+
_workflow_is_finalized,
|
|
91
|
+
)
|
|
92
|
+
from multi_agent_brief.orchestrator.run_integrity import (
|
|
93
|
+
contamination_event_metadata as _run_integrity_contamination_event_metadata,
|
|
94
|
+
contaminate_run_integrity_with_event_flag as _contaminate_run_integrity_with_event_flag,
|
|
95
|
+
workflow_with_persistable_run_integrity as _workflow_with_persistable_run_integrity,
|
|
96
|
+
)
|
|
97
|
+
from multi_agent_brief.orchestrator_contract import resolve_repo_workdir
|
|
98
|
+
from multi_agent_brief.quality_gates.contract import current_stage_quality_gate_blocking_reasons
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
def _remove_reset_archive_copy(path: Path | None) -> None:
|
|
102
|
+
if path is None:
|
|
103
|
+
return
|
|
104
|
+
try:
|
|
105
|
+
path.unlink(missing_ok=True)
|
|
106
|
+
except OSError as exc:
|
|
107
|
+
raise RuntimeStateError(
|
|
108
|
+
"Failed to remove reset event-log archive after partial write.",
|
|
109
|
+
details={"path": str(path), "reason": str(exc)},
|
|
110
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
111
|
+
) from exc
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
def _reset_run_scoped_control_artifact_paths(workspace: Path) -> list[Path]:
|
|
115
|
+
intermediate = workspace / "output" / "intermediate"
|
|
116
|
+
return [
|
|
117
|
+
intermediate / "human_approval_ledger.json",
|
|
118
|
+
intermediate / "release_readiness_report.json",
|
|
119
|
+
intermediate / "quality_panel.json",
|
|
120
|
+
intermediate / "quality_summary.md",
|
|
121
|
+
intermediate / "quality_panel.html",
|
|
122
|
+
intermediate / "guidance_manifestation_report.json",
|
|
123
|
+
]
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _archive_reset_run_scoped_control_artifact(path: Path, *, old_run_id: str) -> Path | None:
|
|
127
|
+
if not path.exists():
|
|
128
|
+
return None
|
|
129
|
+
archive = path.with_name(f"{path.stem}.{old_run_id}{path.suffix}")
|
|
130
|
+
if archive.exists():
|
|
131
|
+
archive = path.with_name(f"{path.stem}.{old_run_id}.{uuid.uuid4().hex[:8]}{path.suffix}")
|
|
132
|
+
try:
|
|
133
|
+
os.replace(path, archive)
|
|
134
|
+
except OSError as exc:
|
|
135
|
+
raise RuntimeStateError(
|
|
136
|
+
"Failed to archive run-scoped control artifact during runtime reset.",
|
|
137
|
+
details={"path": str(path), "archive": str(archive), "reason": str(exc)},
|
|
138
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
139
|
+
) from exc
|
|
140
|
+
return archive
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
def _restore_reset_control_artifacts(
|
|
144
|
+
snapshots: dict[Path, bytes | None],
|
|
145
|
+
archived_paths: list[Path],
|
|
146
|
+
) -> None:
|
|
147
|
+
rollback_errors: list[str] = []
|
|
148
|
+
for path, data in snapshots.items():
|
|
149
|
+
try:
|
|
150
|
+
_restore_state_bytes(path, data)
|
|
151
|
+
except RuntimeStateError as exc:
|
|
152
|
+
rollback_errors.append(str(exc))
|
|
153
|
+
for archived_path in archived_paths:
|
|
154
|
+
try:
|
|
155
|
+
archived_path.unlink(missing_ok=True)
|
|
156
|
+
except OSError as exc:
|
|
157
|
+
rollback_errors.append(f"Failed to remove reset control artifact archive {archived_path}: {exc}")
|
|
158
|
+
if rollback_errors:
|
|
159
|
+
raise RuntimeStateError(
|
|
160
|
+
"Runtime state reset failed to restore run-scoped control artifacts.",
|
|
161
|
+
details={"rollback_errors": rollback_errors},
|
|
162
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
163
|
+
)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def initialize_runtime_state(
|
|
167
|
+
*,
|
|
168
|
+
workspace: str | Path,
|
|
169
|
+
runtime: str = "hermes",
|
|
170
|
+
repo_workdir: str | Path | None = None,
|
|
171
|
+
reset_state: bool = False,
|
|
172
|
+
actor: str = "cli",
|
|
173
|
+
recipe: str | None = None,
|
|
174
|
+
) -> dict[str, Any]:
|
|
175
|
+
"""Initialize runtime control files for a workspace."""
|
|
176
|
+
ws = _require_workspace(workspace)
|
|
177
|
+
repo = resolve_repo_workdir(repo_workdir, workspace=ws)
|
|
178
|
+
paths = runtime_state_paths(ws)
|
|
179
|
+
paths["runtime_manifest"].parent.mkdir(parents=True, exist_ok=True)
|
|
180
|
+
|
|
181
|
+
stages = load_stage_specs(repo)
|
|
182
|
+
artifacts = load_artifact_contracts(repo)
|
|
183
|
+
|
|
184
|
+
if reset_state:
|
|
185
|
+
try:
|
|
186
|
+
old_manifest = _read_json_if_exists(paths["runtime_manifest"])
|
|
187
|
+
except RuntimeStateError:
|
|
188
|
+
old_manifest = None
|
|
189
|
+
try:
|
|
190
|
+
old_workflow = _read_json_if_exists(paths["workflow_state"])
|
|
191
|
+
except RuntimeStateError:
|
|
192
|
+
old_workflow = None
|
|
193
|
+
else:
|
|
194
|
+
old_manifest = _read_json_if_exists(paths["runtime_manifest"])
|
|
195
|
+
old_workflow = _read_json_if_exists(paths["workflow_state"])
|
|
196
|
+
now = utc_now()
|
|
197
|
+
created = old_manifest is None or reset_state
|
|
198
|
+
previous_run_id = _safe_previous_run_id((old_manifest or {}).get("run_id")) if reset_state else None
|
|
199
|
+
archived_event_log: str | None = None
|
|
200
|
+
reset_contamination_reason_added = False
|
|
201
|
+
reset_touched_existing_state = bool(
|
|
202
|
+
reset_state
|
|
203
|
+
and (
|
|
204
|
+
old_manifest is not None
|
|
205
|
+
or old_workflow is not None
|
|
206
|
+
or paths["event_log"].exists()
|
|
207
|
+
)
|
|
208
|
+
)
|
|
209
|
+
reset_snapshots = (
|
|
210
|
+
_snapshot_state_files(paths, ("runtime_manifest", "workflow_state", "event_log"))
|
|
211
|
+
if reset_state
|
|
212
|
+
else {}
|
|
213
|
+
)
|
|
214
|
+
reset_control_artifact_paths = _reset_run_scoped_control_artifact_paths(ws) if reset_state else []
|
|
215
|
+
reset_control_artifact_snapshots = (
|
|
216
|
+
{path: _read_state_bytes(path) for path in reset_control_artifact_paths}
|
|
217
|
+
if reset_state
|
|
218
|
+
else {}
|
|
219
|
+
)
|
|
220
|
+
reset_archived_event_log_path: Path | None = None
|
|
221
|
+
reset_archived_control_artifact_paths: list[Path] = []
|
|
222
|
+
|
|
223
|
+
if reset_state:
|
|
224
|
+
if old_manifest and _workflow_is_finalized(old_workflow):
|
|
225
|
+
old_registry = _read_json(paths["artifact_registry"])
|
|
226
|
+
finalize_report = _read_json(paths["runtime_manifest"].parent / "finalize_report.json")
|
|
227
|
+
archive_result = _archive_finalized_state_if_needed(
|
|
228
|
+
workspace=ws,
|
|
229
|
+
manifest=old_manifest,
|
|
230
|
+
workflow=old_workflow or {},
|
|
231
|
+
artifact_registry=old_registry,
|
|
232
|
+
finalize_report=finalize_report,
|
|
233
|
+
)
|
|
234
|
+
append_event(
|
|
235
|
+
workspace=ws,
|
|
236
|
+
run_id=str(old_manifest["run_id"]),
|
|
237
|
+
event_type="run_archived",
|
|
238
|
+
actor=actor,
|
|
239
|
+
stage_id="finalize",
|
|
240
|
+
reason="Finalized run archived before runtime state reset.",
|
|
241
|
+
metadata={
|
|
242
|
+
"archive_path": _workspace_relative(ws, Path(str(archive_result["archive_path"]))),
|
|
243
|
+
"archive_manifest": _workspace_relative(ws, Path(str(archive_result["archive_manifest"]))),
|
|
244
|
+
"archive_manifest_sha256": archive_result["archive_manifest_sha256"],
|
|
245
|
+
"file_count": archive_result["file_count"],
|
|
246
|
+
"event_log_includes_run_archived": False,
|
|
247
|
+
},
|
|
248
|
+
)
|
|
249
|
+
old_run_id = previous_run_id or "unknown"
|
|
250
|
+
for control_artifact_path in reset_control_artifact_paths:
|
|
251
|
+
archived_control_artifact = _archive_reset_run_scoped_control_artifact(
|
|
252
|
+
control_artifact_path,
|
|
253
|
+
old_run_id=old_run_id,
|
|
254
|
+
)
|
|
255
|
+
if archived_control_artifact is not None:
|
|
256
|
+
reset_archived_control_artifact_paths.append(archived_control_artifact)
|
|
257
|
+
if paths["event_log"].exists():
|
|
258
|
+
archive = paths["event_log"].with_name(f"event_log.{old_run_id}.jsonl")
|
|
259
|
+
if archive.exists():
|
|
260
|
+
archive = paths["event_log"].with_name(
|
|
261
|
+
f"event_log.{old_run_id}.{uuid.uuid4().hex[:8]}.jsonl"
|
|
262
|
+
)
|
|
263
|
+
os.replace(paths["event_log"], archive)
|
|
264
|
+
reset_archived_event_log_path = archive
|
|
265
|
+
archived_event_log = _workspace_relative(ws, archive)
|
|
266
|
+
elif old_manifest and old_manifest.get("schema_version") != RUNTIME_MANIFEST_SCHEMA:
|
|
267
|
+
raise RuntimeStateError(
|
|
268
|
+
"Existing runtime_manifest.json has an unsupported schema. "
|
|
269
|
+
"Use --reset-state to start a new runtime state.",
|
|
270
|
+
details={
|
|
271
|
+
"path": str(paths["runtime_manifest"]),
|
|
272
|
+
"schema_version": old_manifest.get("schema_version"),
|
|
273
|
+
},
|
|
274
|
+
)
|
|
275
|
+
|
|
276
|
+
if old_manifest and not reset_state:
|
|
277
|
+
run_id = _validate_runtime_run_id(
|
|
278
|
+
old_manifest.get("run_id") or new_run_id(),
|
|
279
|
+
path=paths["runtime_manifest"],
|
|
280
|
+
)
|
|
281
|
+
created_at = str(old_manifest.get("created_at") or now)
|
|
282
|
+
else:
|
|
283
|
+
run_id = _validate_runtime_run_id(new_run_id())
|
|
284
|
+
created_at = now
|
|
285
|
+
|
|
286
|
+
manifest = _runtime_manifest(
|
|
287
|
+
run_id=run_id,
|
|
288
|
+
created_at=created_at,
|
|
289
|
+
updated_at=now,
|
|
290
|
+
runtime=runtime,
|
|
291
|
+
stages=stages,
|
|
292
|
+
artifacts=artifacts,
|
|
293
|
+
)
|
|
294
|
+
if old_manifest and not reset_state:
|
|
295
|
+
for key in PRESERVED_RUNTIME_MANIFEST_EXTENSION_KEYS:
|
|
296
|
+
if key in old_manifest:
|
|
297
|
+
manifest[key] = old_manifest[key]
|
|
298
|
+
if recipe is not None:
|
|
299
|
+
manifest["recipe"] = str(recipe)
|
|
300
|
+
|
|
301
|
+
if old_workflow and not reset_state:
|
|
302
|
+
if old_workflow.get("schema_version") != WORKFLOW_STATE_SCHEMA:
|
|
303
|
+
raise RuntimeStateError(
|
|
304
|
+
"Existing workflow_state.json has an unsupported schema. "
|
|
305
|
+
"Use --reset-state to start a new runtime state.",
|
|
306
|
+
details={
|
|
307
|
+
"path": str(paths["workflow_state"]),
|
|
308
|
+
"schema_version": old_workflow.get("schema_version"),
|
|
309
|
+
},
|
|
310
|
+
)
|
|
311
|
+
workflow = _workflow_with_persistable_run_integrity(
|
|
312
|
+
old_workflow,
|
|
313
|
+
path=paths["workflow_state"],
|
|
314
|
+
)
|
|
315
|
+
workflow["updated_at"] = now
|
|
316
|
+
workflow["run_id"] = run_id
|
|
317
|
+
else:
|
|
318
|
+
workflow = _initial_workflow_state(
|
|
319
|
+
run_id=run_id,
|
|
320
|
+
stages=stages,
|
|
321
|
+
created_at=created_at,
|
|
322
|
+
updated_at=now,
|
|
323
|
+
)
|
|
324
|
+
if reset_touched_existing_state:
|
|
325
|
+
workflow, reset_contamination_reason_added = _contaminate_run_integrity_with_event_flag(
|
|
326
|
+
workflow,
|
|
327
|
+
reason_code="run_reset",
|
|
328
|
+
message="run_reset occurred; this run is not clean single-shot reference evidence.",
|
|
329
|
+
created_at=now,
|
|
330
|
+
event_type="run_reset",
|
|
331
|
+
metadata={
|
|
332
|
+
"previous_run_id": previous_run_id,
|
|
333
|
+
"archived_event_log": archived_event_log,
|
|
334
|
+
},
|
|
335
|
+
)
|
|
336
|
+
|
|
337
|
+
try:
|
|
338
|
+
_write_json_atomic(paths["runtime_manifest"], manifest)
|
|
339
|
+
_write_json_atomic(paths["workflow_state"], workflow)
|
|
340
|
+
|
|
341
|
+
if created:
|
|
342
|
+
append_event(
|
|
343
|
+
workspace=ws,
|
|
344
|
+
run_id=run_id,
|
|
345
|
+
event_type="run_reset" if reset_state else "run_initialized",
|
|
346
|
+
actor=actor,
|
|
347
|
+
reason="Runtime state reset." if reset_state else "Runtime state initialized.",
|
|
348
|
+
metadata={
|
|
349
|
+
"runtime": runtime,
|
|
350
|
+
"previous_run_id": previous_run_id,
|
|
351
|
+
"archived_event_log": archived_event_log,
|
|
352
|
+
} if reset_state else {"runtime": runtime},
|
|
353
|
+
)
|
|
354
|
+
if reset_state and reset_contamination_reason_added:
|
|
355
|
+
reasons = (workflow.get("run_integrity") or {}).get("reasons")
|
|
356
|
+
reason = reasons[-1] if isinstance(reasons, list) and reasons and isinstance(reasons[-1], dict) else {}
|
|
357
|
+
append_event(
|
|
358
|
+
workspace=ws,
|
|
359
|
+
run_id=run_id,
|
|
360
|
+
event_type="run_integrity_contaminated",
|
|
361
|
+
actor=actor,
|
|
362
|
+
reason=str(reason.get("message") or "Runtime state reset contaminated run integrity."),
|
|
363
|
+
metadata=_run_integrity_contamination_event_metadata(reason),
|
|
364
|
+
)
|
|
365
|
+
except RuntimeStateError as exc:
|
|
366
|
+
if reset_state:
|
|
367
|
+
try:
|
|
368
|
+
_restore_state_files(paths, reset_snapshots)
|
|
369
|
+
_restore_reset_control_artifacts(
|
|
370
|
+
reset_control_artifact_snapshots,
|
|
371
|
+
reset_archived_control_artifact_paths,
|
|
372
|
+
)
|
|
373
|
+
_remove_reset_archive_copy(reset_archived_event_log_path)
|
|
374
|
+
except RuntimeStateError as rollback_exc:
|
|
375
|
+
raise RuntimeStateError(
|
|
376
|
+
"Runtime state reset partially wrote control files and failed rollback.",
|
|
377
|
+
details={
|
|
378
|
+
"event_error": str(exc),
|
|
379
|
+
"rollback_error": str(rollback_exc),
|
|
380
|
+
},
|
|
381
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
382
|
+
) from rollback_exc
|
|
383
|
+
raise RuntimeStateError(
|
|
384
|
+
"Runtime state reset event append failed; control files were restored.",
|
|
385
|
+
details={"event_error": str(exc), "event_details": exc.details},
|
|
386
|
+
error_code=E_TRANSACTION_PARTIAL_WRITE,
|
|
387
|
+
) from exc
|
|
388
|
+
raise
|
|
389
|
+
|
|
390
|
+
return show_runtime_state(workspace=ws)
|
|
391
|
+
|
|
392
|
+
|
|
393
|
+
def show_runtime_state(*, workspace: str | Path) -> dict[str, Any]:
|
|
394
|
+
ws, paths, manifest, workflow = _load_manifest_and_workflow(workspace)
|
|
395
|
+
registry = _read_json_if_exists(paths["artifact_registry"])
|
|
396
|
+
event_count = 0
|
|
397
|
+
if paths["event_log"].exists():
|
|
398
|
+
try:
|
|
399
|
+
event_count = sum(1 for _ in paths["event_log"].open(encoding="utf-8"))
|
|
400
|
+
except OSError:
|
|
401
|
+
event_count = 0
|
|
402
|
+
state = {
|
|
403
|
+
"ok": True,
|
|
404
|
+
"workspace": str(ws),
|
|
405
|
+
"runtime_state_files": dict(RUNTIME_STATE_FILES),
|
|
406
|
+
"manifest": manifest,
|
|
407
|
+
"workflow_state": workflow,
|
|
408
|
+
"artifact_registry": registry,
|
|
409
|
+
"event_count": event_count,
|
|
410
|
+
}
|
|
411
|
+
state["fact_layer_import"] = summarize_fact_layer_import(manifest, workflow, workspace=ws)
|
|
412
|
+
return state
|
|
413
|
+
|
|
414
|
+
|
|
415
|
+
def _recompute_stage_state(
|
|
416
|
+
*,
|
|
417
|
+
workspace: Path,
|
|
418
|
+
stages: list[dict[str, Any]],
|
|
419
|
+
artifacts: list[dict[str, Any]],
|
|
420
|
+
registry: dict[str, Any],
|
|
421
|
+
previous_workflow: dict[str, Any],
|
|
422
|
+
updated_at: str,
|
|
423
|
+
) -> dict[str, Any]:
|
|
424
|
+
previous_statuses = previous_workflow.get("stage_statuses") or {}
|
|
425
|
+
artifact_records = registry.get("artifacts") or {}
|
|
426
|
+
artifacts_by_id = _artifact_map(artifacts)
|
|
427
|
+
new_statuses: dict[str, dict[str, Any]] = {}
|
|
428
|
+
current_stage: str | None = None
|
|
429
|
+
blocked = False
|
|
430
|
+
blocking_reason = ""
|
|
431
|
+
|
|
432
|
+
for stage in stages:
|
|
433
|
+
stage_id = str(stage.get("stage_id") or "")
|
|
434
|
+
if not stage_id:
|
|
435
|
+
continue
|
|
436
|
+
|
|
437
|
+
previous = previous_statuses.get(stage_id) or {}
|
|
438
|
+
previous_status = str(previous.get("status") or STAGE_PENDING)
|
|
439
|
+
if previous_status in {STAGE_COMPLETE, STAGE_SKIPPED}:
|
|
440
|
+
metadata = previous.get("metadata") if isinstance(previous.get("metadata"), dict) else None
|
|
441
|
+
new_statuses[stage_id] = _status_entry(
|
|
442
|
+
previous_status,
|
|
443
|
+
str(previous.get("reason") or ""),
|
|
444
|
+
str(previous.get("updated_at") or updated_at),
|
|
445
|
+
metadata=metadata,
|
|
446
|
+
)
|
|
447
|
+
continue
|
|
448
|
+
|
|
449
|
+
if current_stage is not None:
|
|
450
|
+
new_statuses[stage_id] = _status_entry(STAGE_PENDING, "", updated_at)
|
|
451
|
+
continue
|
|
452
|
+
|
|
453
|
+
last_decision = previous_workflow.get("last_decision") or {}
|
|
454
|
+
if (
|
|
455
|
+
previous_status == STAGE_BLOCKED
|
|
456
|
+
and last_decision.get("stage_id") == stage_id
|
|
457
|
+
and last_decision.get("decision") in {"request_human_review", "block_run"}
|
|
458
|
+
):
|
|
459
|
+
current_stage = stage_id
|
|
460
|
+
blocked = True
|
|
461
|
+
blocking_reason = str(previous.get("reason") or last_decision.get("reason") or "")
|
|
462
|
+
new_statuses[stage_id] = _status_entry(STAGE_BLOCKED, blocking_reason, updated_at)
|
|
463
|
+
continue
|
|
464
|
+
|
|
465
|
+
reasons: list[str] = []
|
|
466
|
+
for artifact_id in _required_consumed_artifacts(stage=stage, artifacts_by_id=artifacts_by_id):
|
|
467
|
+
record = artifact_records.get(artifact_id) or {}
|
|
468
|
+
if record.get("status") != ARTIFACT_VALID:
|
|
469
|
+
reasons.append(
|
|
470
|
+
f"Required artifact '{artifact_id}' is {record.get('status', ARTIFACT_EXPECTED)}."
|
|
471
|
+
)
|
|
472
|
+
|
|
473
|
+
for artifact_id in stage.get("expected_artifacts") or []:
|
|
474
|
+
record = artifact_records.get(str(artifact_id)) or {}
|
|
475
|
+
if record.get("status") == ARTIFACT_INVALID:
|
|
476
|
+
reasons.append(
|
|
477
|
+
f"Expected output artifact '{artifact_id}' is invalid."
|
|
478
|
+
)
|
|
479
|
+
|
|
480
|
+
reasons.extend(
|
|
481
|
+
current_stage_feedback_blocking_reasons(
|
|
482
|
+
workspace=workspace,
|
|
483
|
+
current_stage=stage_id,
|
|
484
|
+
stages=stages,
|
|
485
|
+
artifacts=artifacts,
|
|
486
|
+
)
|
|
487
|
+
)
|
|
488
|
+
reasons.extend(
|
|
489
|
+
current_stage_quality_gate_blocking_reasons(
|
|
490
|
+
workspace=workspace,
|
|
491
|
+
current_stage=stage_id,
|
|
492
|
+
stages=stages,
|
|
493
|
+
artifacts=artifacts,
|
|
494
|
+
)
|
|
495
|
+
)
|
|
496
|
+
|
|
497
|
+
if reasons:
|
|
498
|
+
current_stage = stage_id
|
|
499
|
+
blocked = True
|
|
500
|
+
blocking_reason = " ".join(reasons)
|
|
501
|
+
new_statuses[stage_id] = _status_entry(STAGE_BLOCKED, blocking_reason, updated_at)
|
|
502
|
+
else:
|
|
503
|
+
current_stage = stage_id
|
|
504
|
+
new_statuses[stage_id] = _status_entry(STAGE_READY, "", updated_at)
|
|
505
|
+
|
|
506
|
+
workflow = dict(previous_workflow)
|
|
507
|
+
workflow["updated_at"] = updated_at
|
|
508
|
+
workflow["current_stage"] = current_stage
|
|
509
|
+
workflow["blocked"] = blocked
|
|
510
|
+
workflow["blocking_reason"] = blocking_reason
|
|
511
|
+
workflow["stage_statuses"] = new_statuses
|
|
512
|
+
workflow["next_allowed_decisions"] = _allowed_decisions_for_stage(stages, current_stage)
|
|
513
|
+
return workflow
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
def check_runtime_state(
|
|
517
|
+
*,
|
|
518
|
+
workspace: str | Path,
|
|
519
|
+
repo_workdir: str | Path | None = None,
|
|
520
|
+
actor: str = "cli",
|
|
521
|
+
) -> dict[str, Any]:
|
|
522
|
+
"""Refresh artifact registry and stage readiness without running stages."""
|
|
523
|
+
ws = _require_workspace(workspace)
|
|
524
|
+
paths = runtime_state_paths(ws)
|
|
525
|
+
if not paths["runtime_manifest"].exists() or not paths["workflow_state"].exists():
|
|
526
|
+
initialize_runtime_state(workspace=ws, repo_workdir=repo_workdir, actor=actor)
|
|
527
|
+
|
|
528
|
+
ws, paths, manifest, workflow = _load_manifest_and_workflow(ws)
|
|
529
|
+
event_records = _read_event_log_records(paths["event_log"])
|
|
530
|
+
old_registry = _read_json_if_exists(paths["artifact_registry"])
|
|
531
|
+
repo = resolve_repo_workdir(repo_workdir, workspace=ws)
|
|
532
|
+
stages = load_stage_specs(repo)
|
|
533
|
+
artifacts = load_artifact_contracts(repo)
|
|
534
|
+
now = utc_now()
|
|
535
|
+
run_id = str(manifest["run_id"])
|
|
536
|
+
|
|
537
|
+
registry = _build_artifact_registry(
|
|
538
|
+
workspace=ws,
|
|
539
|
+
run_id=run_id,
|
|
540
|
+
artifacts=artifacts,
|
|
541
|
+
workflow=workflow,
|
|
542
|
+
updated_at=now,
|
|
543
|
+
)
|
|
544
|
+
frozen_verdict = interpret_frozen_artifact_integrity(
|
|
545
|
+
old_registry=old_registry,
|
|
546
|
+
registry=registry,
|
|
547
|
+
workflow=workflow,
|
|
548
|
+
artifacts=artifacts,
|
|
549
|
+
stages=stages,
|
|
550
|
+
mutating_stage=str(workflow.get("current_stage") or ""),
|
|
551
|
+
)
|
|
552
|
+
frozen_reasons = require_frozen_artifact_integrity_pass(frozen_verdict)
|
|
553
|
+
if frozen_reasons:
|
|
554
|
+
if frozen_verdict.contaminates_run:
|
|
555
|
+
workflow = _persist_run_contamination(
|
|
556
|
+
workspace=ws,
|
|
557
|
+
paths=paths,
|
|
558
|
+
run_id=run_id,
|
|
559
|
+
workflow=workflow,
|
|
560
|
+
reason_code="frozen_artifact_changed",
|
|
561
|
+
message=" ".join(frozen_reasons),
|
|
562
|
+
actor=actor,
|
|
563
|
+
stage_id=str(workflow.get("current_stage") or ""),
|
|
564
|
+
metadata={"blocking_reasons": frozen_reasons},
|
|
565
|
+
)
|
|
566
|
+
_raise_completion_reasons(
|
|
567
|
+
message=(
|
|
568
|
+
"Runtime state integrity check failed because a frozen artifact changed"
|
|
569
|
+
if frozen_verdict.contaminates_run
|
|
570
|
+
else "Runtime state integrity check failed because frozen artifact integrity could not be verified"
|
|
571
|
+
),
|
|
572
|
+
reasons=frozen_reasons,
|
|
573
|
+
error_code=E_TRANSACTION_INTEGRITY,
|
|
574
|
+
details={"stage_id": workflow.get("current_stage")},
|
|
575
|
+
)
|
|
576
|
+
refreshed_workflow = _recompute_stage_state(
|
|
577
|
+
workspace=ws,
|
|
578
|
+
stages=stages,
|
|
579
|
+
artifacts=artifacts,
|
|
580
|
+
registry=registry,
|
|
581
|
+
previous_workflow=workflow,
|
|
582
|
+
updated_at=now,
|
|
583
|
+
)
|
|
584
|
+
refreshed_workflow = _workflow_with_trajectory_decision_narrowing(
|
|
585
|
+
workspace=ws,
|
|
586
|
+
workflow=refreshed_workflow,
|
|
587
|
+
stages=stages,
|
|
588
|
+
event_records=event_records,
|
|
589
|
+
run_id=run_id,
|
|
590
|
+
)
|
|
591
|
+
transaction_integrity_warning = _completion_transaction_integrity_reason(
|
|
592
|
+
paths=paths,
|
|
593
|
+
workflow=refreshed_workflow,
|
|
594
|
+
)
|
|
595
|
+
if transaction_integrity_warning:
|
|
596
|
+
refreshed_workflow["blocked"] = True
|
|
597
|
+
refreshed_workflow["blocking_reason"] = transaction_integrity_warning
|
|
598
|
+
current_stage = refreshed_workflow.get("current_stage")
|
|
599
|
+
if current_stage:
|
|
600
|
+
statuses = dict(refreshed_workflow.get("stage_statuses") or {})
|
|
601
|
+
statuses[str(current_stage)] = _status_entry(
|
|
602
|
+
STAGE_BLOCKED,
|
|
603
|
+
transaction_integrity_warning,
|
|
604
|
+
now,
|
|
605
|
+
)
|
|
606
|
+
refreshed_workflow["stage_statuses"] = statuses
|
|
607
|
+
|
|
608
|
+
planned_events = [
|
|
609
|
+
*_changed_artifact_events(old_registry=old_registry, registry=registry),
|
|
610
|
+
*_changed_workflow_events(old_workflow=workflow, workflow=refreshed_workflow),
|
|
611
|
+
]
|
|
612
|
+
if _trajectory_narrowing_changed(workflow, refreshed_workflow):
|
|
613
|
+
narrowing = refreshed_workflow.get("trajectory_regulation")
|
|
614
|
+
if isinstance(narrowing, dict) and narrowing.get("status") == TRAJECTORY_DECISION_NARROWING_STATUS:
|
|
615
|
+
planned_events.append({
|
|
616
|
+
"event_type": "trajectory_decision_narrowed",
|
|
617
|
+
"stage_id": narrowing.get("stage_id"),
|
|
618
|
+
"reason": ", ".join(str(item) for item in narrowing.get("reasons") or []),
|
|
619
|
+
"metadata": {
|
|
620
|
+
"allowed_decisions": list(narrowing.get("allowed_decisions") or []),
|
|
621
|
+
"recommended_actions": list(narrowing.get("recommended_actions") or []),
|
|
622
|
+
},
|
|
623
|
+
})
|
|
624
|
+
for event in planned_events:
|
|
625
|
+
append_event(
|
|
626
|
+
workspace=ws,
|
|
627
|
+
run_id=run_id,
|
|
628
|
+
event_type=str(event["event_type"]),
|
|
629
|
+
actor=actor,
|
|
630
|
+
stage_id=event.get("stage_id"),
|
|
631
|
+
artifact_id=event.get("artifact_id"),
|
|
632
|
+
reason=str(event.get("reason") or ""),
|
|
633
|
+
metadata=event.get("metadata") or {},
|
|
634
|
+
)
|
|
635
|
+
|
|
636
|
+
_write_json_atomic(paths["artifact_registry"], registry)
|
|
637
|
+
_write_json_atomic(paths["workflow_state"], refreshed_workflow)
|
|
638
|
+
|
|
639
|
+
control_switchboard_warning: dict[str, Any] | None = None
|
|
640
|
+
|
|
641
|
+
try:
|
|
642
|
+
from multi_agent_brief.controls.contract import ControlSwitchboardError
|
|
643
|
+
from multi_agent_brief.controls.switchboard import refresh_control_switchboard_if_stale
|
|
644
|
+
|
|
645
|
+
try:
|
|
646
|
+
refresh_control_switchboard_if_stale(
|
|
647
|
+
workspace=ws,
|
|
648
|
+
repo_workdir=repo,
|
|
649
|
+
actor=actor,
|
|
650
|
+
)
|
|
651
|
+
except ControlSwitchboardError as exc:
|
|
652
|
+
control_switchboard_warning = {
|
|
653
|
+
"error": str(exc),
|
|
654
|
+
"details": exc.details,
|
|
655
|
+
}
|
|
656
|
+
append_event(
|
|
657
|
+
workspace=ws,
|
|
658
|
+
run_id=run_id,
|
|
659
|
+
event_type="control_switchboard_warning",
|
|
660
|
+
actor=actor,
|
|
661
|
+
reason=str(exc),
|
|
662
|
+
metadata=exc.details,
|
|
663
|
+
)
|
|
664
|
+
except ImportError:
|
|
665
|
+
pass
|
|
666
|
+
|
|
667
|
+
state = show_runtime_state(workspace=ws)
|
|
668
|
+
if control_switchboard_warning is not None:
|
|
669
|
+
state["control_switchboard_warning"] = control_switchboard_warning
|
|
670
|
+
if transaction_integrity_warning:
|
|
671
|
+
state["transaction_integrity_warning"] = {
|
|
672
|
+
"error_code": E_TRANSACTION_INTEGRITY,
|
|
673
|
+
"message": transaction_integrity_warning,
|
|
674
|
+
}
|
|
675
|
+
return state
|