loopx 0.4.8__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.
- loopx/__init__.py +5 -0
- loopx/agent_onboarding.py +654 -0
- loopx/agent_registry.py +112 -0
- loopx/ark_managed_agent_host.py +59 -0
- loopx/authority.py +805 -0
- loopx/benchmark.py +2875 -0
- loopx/benchmark_adapters/__init__.py +1 -0
- loopx/benchmark_adapters/agentissue.py +2644 -0
- loopx/benchmark_adapters/agents_last_exam.py +3998 -0
- loopx/benchmark_adapters/edgebench.py +322 -0
- loopx/benchmark_adapters/skillsbench.py +5978 -0
- loopx/benchmark_adapters/skillsbench_acp_failure_policy.py +143 -0
- loopx/benchmark_adapters/skillsbench_acp_process.py +31 -0
- loopx/benchmark_adapters/skillsbench_acp_relay.py +4832 -0
- loopx/benchmark_adapters/skillsbench_batch.py +124 -0
- loopx/benchmark_adapters/skillsbench_bridge_guard.py +209 -0
- loopx/benchmark_adapters/skillsbench_bridge_summary.py +203 -0
- loopx/benchmark_adapters/skillsbench_codex_goal_recovery.py +271 -0
- loopx/benchmark_adapters/skillsbench_codex_goal_trace.py +81 -0
- loopx/benchmark_adapters/skillsbench_codex_runtime.py +339 -0
- loopx/benchmark_adapters/skillsbench_dockerfile_runtime.py +467 -0
- loopx/benchmark_adapters/skillsbench_failure_signals.py +652 -0
- loopx/benchmark_adapters/skillsbench_proxy_runtime.py +327 -0
- loopx/benchmark_adapters/skillsbench_remote_bridge.py +402 -0
- loopx/benchmark_adapters/skillsbench_result_discovery.py +143 -0
- loopx/benchmark_adapters/skillsbench_runner_profile.py +436 -0
- loopx/benchmark_adapters/skillsbench_runner_source.py +99 -0
- loopx/benchmark_adapters/skillsbench_setup_preflight.py +771 -0
- loopx/benchmark_adapters/skillsbench_signals.py +15 -0
- loopx/benchmark_adapters/skillsbench_task_source.py +141 -0
- loopx/benchmark_adapters/skillsbench_turn_route.py +723 -0
- loopx/benchmark_adapters/skillsbench_turn_runtime.py +1069 -0
- loopx/benchmark_adapters/skillsbench_typed_repair.py +689 -0
- loopx/benchmark_adapters/skillsbench_uv_cache.py +111 -0
- loopx/benchmark_adapters/skillsbench_verifier_bootstrap.py +227 -0
- loopx/benchmark_adapters/skillsbench_verifier_cache.py +138 -0
- loopx/benchmark_adapters/terminal_bench.py +10078 -0
- loopx/benchmark_case_analysis.py +1276 -0
- loopx/benchmark_case_state.py +1079 -0
- loopx/benchmark_core/__init__.py +239 -0
- loopx/benchmark_core/adapter.py +84 -0
- loopx/benchmark_core/artifacts.py +517 -0
- loopx/benchmark_core/attempts.py +199 -0
- loopx/benchmark_core/container_exec.py +216 -0
- loopx/benchmark_core/io.py +68 -0
- loopx/benchmark_core/lifecycle.py +211 -0
- loopx/benchmark_core/loop_protocol.py +689 -0
- loopx/benchmark_core/observable_handles.py +348 -0
- loopx/benchmark_core/parity.py +256 -0
- loopx/benchmark_core/remote_closeout.py +482 -0
- loopx/benchmark_core/rounds.py +215 -0
- loopx/benchmark_core/route_profile.py +509 -0
- loopx/benchmark_core/run_permissions.py +206 -0
- loopx/benchmark_core/split_control.py +925 -0
- loopx/benchmark_core/turn_fidelity.py +326 -0
- loopx/benchmark_ledger.py +3793 -0
- loopx/benchmark_ledger_countability.py +372 -0
- loopx/benchmark_ledger_current.py +724 -0
- loopx/benchmark_trajectory.py +405 -0
- loopx/benchmarks/__init__.py +1 -0
- loopx/benchmarks/qualification/__init__.py +1 -0
- loopx/benchmarks/qualification/release_outcome_baseline.py +360 -0
- loopx/benchmarks/read_models/__init__.py +1 -0
- loopx/benchmarks/read_models/benchmark_attempt_accounting.py +53 -0
- loopx/benchmarks/read_models/benchmark_comparison.py +414 -0
- loopx/benchmarks/read_models/benchmark_event_timeline.py +113 -0
- loopx/benchmarks/read_models/benchmark_experiment_report.py +475 -0
- loopx/benchmarks/read_models/benchmark_learning_ledger.py +137 -0
- loopx/benchmarks/read_models/benchmark_lifecycle_contracts.py +228 -0
- loopx/benchmarks/read_models/benchmark_projection.py +723 -0
- loopx/benchmarks/read_models/benchmark_result.py +146 -0
- loopx/benchmarks/read_models/benchmark_run_execution_contract.py +116 -0
- loopx/benchmarks/read_models/benchmark_run_failure.py +157 -0
- loopx/benchmarks/read_models/benchmark_run_metrics.py +213 -0
- loopx/benchmarks/read_models/benchmark_run_post_execution.py +635 -0
- loopx/benchmarks/read_models/benchmark_run_pre_execution.py +541 -0
- loopx/benchmarks/read_models/benchmark_status_compaction.py +1255 -0
- loopx/benchmarks/read_models/benchmark_status_runner.py +780 -0
- loopx/benchmarks/read_models/goal_start_control_score.py +857 -0
- loopx/benchmarks/read_models/skillsbench_post_run_debug.py +746 -0
- loopx/benchmarks/read_models/skillsbench_verifier_attribution.py +269 -0
- loopx/bootstrap.py +1116 -0
- loopx/bootstrap_command_pack.py +2167 -0
- loopx/boundary_authority.py +199 -0
- loopx/canary/__init__.py +1 -0
- loopx/canary/maintainability_ratchet.py +800 -0
- loopx/canary/planner.py +1984 -0
- loopx/canary/premerge.py +1130 -0
- loopx/canary/qualification_profiles.py +309 -0
- loopx/canary/quality_surface_catalog.py +838 -0
- loopx/canary/release_profiles.py +51 -0
- loopx/canary/runner.py +1107 -0
- loopx/canary/smoke_health.py +581 -0
- loopx/canary/smoke_profiles.py +212 -0
- loopx/capabilities/__init__.py +0 -0
- loopx/capabilities/agent_turn_recall/__init__.py +17 -0
- loopx/capabilities/agent_turn_recall/cli.py +369 -0
- loopx/capabilities/agent_turn_recall/core.py +296 -0
- loopx/capabilities/auto_research/__init__.py +16 -0
- loopx/capabilities/auto_research/bootstrap_contract.py +157 -0
- loopx/capabilities/auto_research/cli.py +1468 -0
- loopx/capabilities/auto_research/core.py +11 -0
- loopx/capabilities/auto_research/defaults.py +79 -0
- loopx/capabilities/auto_research/demo_e2e.py +1848 -0
- loopx/capabilities/auto_research/demo_supervisor.py +186 -0
- loopx/capabilities/auto_research/evidence_packet.py +767 -0
- loopx/capabilities/auto_research/human_view.py +794 -0
- loopx/capabilities/auto_research/kernel.py +191 -0
- loopx/capabilities/auto_research/knn_demo_workspace.py +322 -0
- loopx/capabilities/auto_research/live_evidence.py +248 -0
- loopx/capabilities/auto_research/preset.py +176 -0
- loopx/capabilities/auto_research/research_state.py +1085 -0
- loopx/capabilities/auto_research/role_profiles.py +394 -0
- loopx/capabilities/auto_research/rollout_append.py +97 -0
- loopx/capabilities/auto_research/terminal_result_contract.py +422 -0
- loopx/capabilities/auto_research/terminal_result_projection.py +171 -0
- loopx/capabilities/auto_research/terminal_result_query.py +233 -0
- loopx/capabilities/auto_research/terminal_results.py +349 -0
- loopx/capabilities/auto_research/user_contract.py +190 -0
- loopx/capabilities/auto_research/worker_loop.py +163 -0
- loopx/capabilities/auto_research/worker_runtime.py +777 -0
- loopx/capabilities/auto_research/worker_skill/SKILL.md +343 -0
- loopx/capabilities/benchmark_toolkit/__init__.py +19 -0
- loopx/capabilities/benchmark_toolkit/integrity.py +387 -0
- loopx/capabilities/catalog.py +1875 -0
- loopx/capabilities/change_quality/__init__.py +19 -0
- loopx/capabilities/change_quality/cli.py +171 -0
- loopx/capabilities/change_quality/context.py +156 -0
- loopx/capabilities/change_quality/oracles.py +269 -0
- loopx/capabilities/change_quality/policy.py +34 -0
- loopx/capabilities/change_quality/receipt.py +482 -0
- loopx/capabilities/change_quality/result.py +493 -0
- loopx/capabilities/change_quality/scope.py +171 -0
- loopx/capabilities/change_quality/shadow.py +680 -0
- loopx/capabilities/content_ops/__init__.py +0 -0
- loopx/capabilities/content_ops/cli.py +649 -0
- loopx/capabilities/content_ops/connector_packets.py +164 -0
- loopx/capabilities/content_ops/item_lifecycle.py +1000 -0
- loopx/capabilities/content_ops/layout.py +451 -0
- loopx/capabilities/content_ops/markdown.py +456 -0
- loopx/capabilities/content_ops/schemas.py +51 -0
- loopx/capabilities/content_ops/social_browser_x.py +107 -0
- loopx/capabilities/content_ops/surface.py +1956 -0
- loopx/capabilities/content_ops/templates/layout-catalog-v0.json +72 -0
- loopx/capabilities/context_providers/__init__.py +36 -0
- loopx/capabilities/context_providers/base.py +189 -0
- loopx/capabilities/context_providers/factory.py +32 -0
- loopx/capabilities/context_providers/openviking.py +702 -0
- loopx/capabilities/context_providers/service_ownership.py +185 -0
- loopx/capabilities/decision_context/__init__.py +129 -0
- loopx/capabilities/decision_context/architecture.py +83 -0
- loopx/capabilities/decision_context/assembler.py +849 -0
- loopx/capabilities/decision_context/catalog_entry.py +195 -0
- loopx/capabilities/decision_context/cli.py +310 -0
- loopx/capabilities/decision_context/cursor_commit.py +535 -0
- loopx/capabilities/decision_context/outcome_feedback.py +352 -0
- loopx/capabilities/decision_context/packets.py +654 -0
- loopx/capabilities/decision_context/private_state.py +189 -0
- loopx/capabilities/decision_context/profile.py +453 -0
- loopx/capabilities/decision_context/providers.py +228 -0
- loopx/capabilities/decision_context/review_settlement.py +136 -0
- loopx/capabilities/decision_context/runtime.py +273 -0
- loopx/capabilities/decision_context/sources.py +415 -0
- loopx/capabilities/explore/__init__.py +1 -0
- loopx/capabilities/explore/activation.py +198 -0
- loopx/capabilities/explore/adaptive_replay_planner.py +221 -0
- loopx/capabilities/explore/child_replay_runtime.py +463 -0
- loopx/capabilities/explore/composition_frontier.py +291 -0
- loopx/capabilities/explore/counterfactual_runtime.py +578 -0
- loopx/capabilities/explore/episode_runtime.py +647 -0
- loopx/capabilities/explore/harness_checkpoint.py +171 -0
- loopx/capabilities/explore/harness_gate.py +115 -0
- loopx/capabilities/explore/harness_runtime.py +1124 -0
- loopx/capabilities/explore/replay_metrics.py +206 -0
- loopx/capabilities/explore/replay_runtime.py +1271 -0
- loopx/capabilities/explore/resource_portfolio.py +173 -0
- loopx/capabilities/explore/result_log.py +974 -0
- loopx/capabilities/explore/router_state.py +432 -0
- loopx/capabilities/explore/source_history_reconcile.py +255 -0
- loopx/capabilities/explore/speculative_scheduler.py +498 -0
- loopx/capabilities/explore/todo_branch_plan.py +650 -0
- loopx/capabilities/explore/todo_evidence.py +141 -0
- loopx/capabilities/explore/trace_runtime.py +284 -0
- loopx/capabilities/explore/worker_branch_plan.py +1257 -0
- loopx/capabilities/integration_branch/__init__.py +13 -0
- loopx/capabilities/integration_branch/cli.py +148 -0
- loopx/capabilities/integration_branch/core.py +916 -0
- loopx/capabilities/issue_fix/__init__.py +19 -0
- loopx/capabilities/issue_fix/acceptance_loop.py +1050 -0
- loopx/capabilities/issue_fix/candidate_evidence.py +503 -0
- loopx/capabilities/issue_fix/candidate_preflight.py +676 -0
- loopx/capabilities/issue_fix/cli.py +1822 -0
- loopx/capabilities/issue_fix/cli_input.py +87 -0
- loopx/capabilities/issue_fix/content_ops_cli.py +148 -0
- loopx/capabilities/issue_fix/discovered_issue_promotion.py +947 -0
- loopx/capabilities/issue_fix/explore_projection.py +710 -0
- loopx/capabilities/issue_fix/feasibility.py +542 -0
- loopx/capabilities/issue_fix/github_public.py +661 -0
- loopx/capabilities/issue_fix/intake_surface.py +832 -0
- loopx/capabilities/issue_fix/metadata_preview.py +218 -0
- loopx/capabilities/issue_fix/metrics_projection.py +1340 -0
- loopx/capabilities/issue_fix/metrics_supplement.py +634 -0
- loopx/capabilities/issue_fix/metrics_supplement_cli.py +127 -0
- loopx/capabilities/issue_fix/outcome_projection.py +1235 -0
- loopx/capabilities/issue_fix/periodic_report.py +189 -0
- loopx/capabilities/issue_fix/pr_description.py +418 -0
- loopx/capabilities/issue_fix/pr_gate_reconcile.py +496 -0
- loopx/capabilities/issue_fix/pr_gate_reconcile_cli.py +464 -0
- loopx/capabilities/issue_fix/pr_lifecycle.py +1327 -0
- loopx/capabilities/issue_fix/pr_lifecycle_rollout.py +85 -0
- loopx/capabilities/issue_fix/pr_monitor_materialization.py +257 -0
- loopx/capabilities/issue_fix/pr_review_ack.py +439 -0
- loopx/capabilities/issue_fix/provider_hooks.py +24 -0
- loopx/capabilities/issue_fix/repository_commit_evidence.py +186 -0
- loopx/capabilities/issue_fix/repository_context.py +457 -0
- loopx/capabilities/issue_fix/repository_memory.py +459 -0
- loopx/capabilities/issue_fix/repository_memory_provider.py +1454 -0
- loopx/capabilities/issue_fix/repository_snapshot.py +454 -0
- loopx/capabilities/issue_fix/reviewer_cli.py +917 -0
- loopx/capabilities/issue_fix/reviewer_notification.py +882 -0
- loopx/capabilities/issue_fix/reviewer_notification_drain.py +942 -0
- loopx/capabilities/issue_fix/reviewer_recommendation.py +1057 -0
- loopx/capabilities/issue_fix/reviewer_request.py +1282 -0
- loopx/capabilities/issue_fix/reward_memory.py +879 -0
- loopx/capabilities/issue_fix/workflow_plan.py +1286 -0
- loopx/capabilities/material_lifecycle/__init__.py +161 -0
- loopx/capabilities/material_lifecycle/_validation.py +183 -0
- loopx/capabilities/material_lifecycle/apply.py +672 -0
- loopx/capabilities/material_lifecycle/architecture.py +122 -0
- loopx/capabilities/material_lifecycle/cli.py +161 -0
- loopx/capabilities/material_lifecycle/decision_planning.py +470 -0
- loopx/capabilities/material_lifecycle/explore_execution.py +306 -0
- loopx/capabilities/material_lifecycle/intake.py +869 -0
- loopx/capabilities/material_lifecycle/inventory.py +147 -0
- loopx/capabilities/material_lifecycle/lifecycle.py +98 -0
- loopx/capabilities/material_lifecycle/preparation.py +147 -0
- loopx/capabilities/material_lifecycle/project_skill.py +83 -0
- loopx/capabilities/material_lifecycle/ranking.py +267 -0
- loopx/capabilities/material_lifecycle/readable_projection.py +500 -0
- loopx/capabilities/material_lifecycle/rebuild.py +480 -0
- loopx/capabilities/material_lifecycle/settlement.py +238 -0
- loopx/capabilities/periodic_report/__init__.py +71 -0
- loopx/capabilities/periodic_report/adapters.py +939 -0
- loopx/capabilities/periodic_report/archive.py +422 -0
- loopx/capabilities/periodic_report/bindings.py +705 -0
- loopx/capabilities/periodic_report/cli.py +277 -0
- loopx/capabilities/periodic_report/core.py +691 -0
- loopx/capabilities/periodic_report/extension_envelope.py +66 -0
- loopx/capabilities/periodic_report/presets.py +103 -0
- loopx/capabilities/periodic_report/profile.py +235 -0
- loopx/capabilities/periodic_report/project_progress.py +179 -0
- loopx/capabilities/periodic_report/triggers.py +452 -0
- loopx/capabilities/pr_review_queue/__init__.py +17 -0
- loopx/capabilities/pr_review_queue/core.py +506 -0
- loopx/capabilities/pr_review_queue/review_contract.py +506 -0
- loopx/capabilities/registry.py +192 -0
- loopx/capabilities/reward_memory/__init__.py +75 -0
- loopx/capabilities/reward_memory/application.py +819 -0
- loopx/capabilities/reward_memory/architecture.py +572 -0
- loopx/capabilities/reward_memory/candidate_review.py +511 -0
- loopx/capabilities/reward_memory/cli.py +469 -0
- loopx/capabilities/reward_memory/dogfood.py +574 -0
- loopx/capabilities/reward_memory/evaluation.py +296 -0
- loopx/capabilities/reward_memory/evaluation_fixtures.py +362 -0
- loopx/capabilities/reward_memory/experiment.py +567 -0
- loopx/capabilities/reward_memory/health.py +222 -0
- loopx/capabilities/reward_memory/ingestion.py +519 -0
- loopx/capabilities/reward_memory/registry.py +600 -0
- loopx/capabilities/reward_memory/runtime_hooks.py +312 -0
- loopx/capabilities/reward_memory/scoped_feedback.py +173 -0
- loopx/capabilities/semantic_preference/__init__.py +12 -0
- loopx/capabilities/semantic_preference/cli.py +189 -0
- loopx/capabilities/semantic_preference/contract.py +592 -0
- loopx/capabilities/semantic_preference/reward_memory.py +62 -0
- loopx/capabilities/value_connectors/__init__.py +1 -0
- loopx/capabilities/value_connectors/cli.py +401 -0
- loopx/capabilities/value_connectors/finance_extension_migration.py +108 -0
- loopx/capabilities/value_connectors/install_check.py +147 -0
- loopx/capabilities/value_connectors/planner.py +733 -0
- loopx/capabilities/value_connectors/source_map.py +446 -0
- loopx/claude_goal_baseline.py +138 -0
- loopx/claude_goal_mode/__init__.py +23 -0
- loopx/claude_goal_mode/hooks/goal_policy.py +212 -0
- loopx/claude_goal_mode/hooks/goal_state.py +139 -0
- loopx/claude_goal_mode/mcp/loopx_mcp.py +167 -0
- loopx/claude_goal_mode/scripts/connect.py +103 -0
- loopx/claude_goal_mode/scripts/goalmode_cmd.py +241 -0
- loopx/claude_goal_mode/scripts/install.py +328 -0
- loopx/claude_goal_mode/statusline/goal_status.py +97 -0
- loopx/cli.py +836 -0
- loopx/cli_commands/__init__.py +334 -0
- loopx/cli_commands/_host_thread.py +13 -0
- loopx/cli_commands/agentissue_runner_flow.py +447 -0
- loopx/cli_commands/agents_last_exam.py +160 -0
- loopx/cli_commands/agents_last_exam_baked_input.py +302 -0
- loopx/cli_commands/agents_last_exam_host_codex.py +374 -0
- loopx/cli_commands/agents_last_exam_launch_dry_run.py +372 -0
- loopx/cli_commands/agents_last_exam_local_plan.py +322 -0
- loopx/cli_commands/agents_last_exam_runner_source.py +352 -0
- loopx/cli_commands/agents_last_exam_task_material.py +335 -0
- loopx/cli_commands/agents_last_exam_validation_gate.py +236 -0
- loopx/cli_commands/benchmark_boundary.py +499 -0
- loopx/cli_commands/benchmark_dispatch.py +161 -0
- loopx/cli_commands/benchmark_release_outcome.py +123 -0
- loopx/cli_commands/benchmark_review_lifecycle.py +1275 -0
- loopx/cli_commands/benchmark_run_ledger.py +763 -0
- loopx/cli_commands/benchmark_run_ledger_case_analysis.py +249 -0
- loopx/cli_commands/benchmark_run_ledger_classification.py +45 -0
- loopx/cli_commands/benchmark_run_ledger_maintenance.py +486 -0
- loopx/cli_commands/benchmark_run_ledger_maintenance_registration.py +342 -0
- loopx/cli_commands/benchmark_run_ledger_maintenance_rendering.py +233 -0
- loopx/cli_commands/benchmark_run_ledger_parity.py +92 -0
- loopx/cli_commands/bootstrap_connect.py +238 -0
- loopx/cli_commands/canary.py +707 -0
- loopx/cli_commands/canary_release_qualification.py +79 -0
- loopx/cli_commands/capability.py +96 -0
- loopx/cli_commands/doctor.py +43 -0
- loopx/cli_commands/dreaming.py +143 -0
- loopx/cli_commands/edgebench.py +205 -0
- loopx/cli_commands/evidence_log.py +275 -0
- loopx/cli_commands/explore.py +989 -0
- loopx/cli_commands/explore_planning_commands.py +157 -0
- loopx/cli_commands/extension.py +271 -0
- loopx/cli_commands/first_run_report.py +73 -0
- loopx/cli_commands/goal_channel.py +656 -0
- loopx/cli_commands/handoff_mode.py +158 -0
- loopx/cli_commands/history.py +622 -0
- loopx/cli_commands/host_mode_plan.py +113 -0
- loopx/cli_commands/lark_inbox.py +431 -0
- loopx/cli_commands/lark_kanban.py +629 -0
- loopx/cli_commands/ml_experiment.py +321 -0
- loopx/cli_commands/multi_agent.py +211 -0
- loopx/cli_commands/opencode2_goal_worker.py +217 -0
- loopx/cli_commands/pr_review.py +167 -0
- loopx/cli_commands/presentation.py +218 -0
- loopx/cli_commands/preset.py +96 -0
- loopx/cli_commands/project.py +150 -0
- loopx/cli_commands/project_lifecycle.py +915 -0
- loopx/cli_commands/quota.py +859 -0
- loopx/cli_commands/quota_registration.py +241 -0
- loopx/cli_commands/quota_request.py +113 -0
- loopx/cli_commands/ready_score.py +110 -0
- loopx/cli_commands/registry_admin.py +975 -0
- loopx/cli_commands/registry_admin_configure.py +344 -0
- loopx/cli_commands/registry_admin_peer.py +84 -0
- loopx/cli_commands/registry_authority.py +218 -0
- loopx/cli_commands/review_batch.py +146 -0
- loopx/cli_commands/slash_commands.py +145 -0
- loopx/cli_commands/start_goal.py +251 -0
- loopx/cli_commands/starter.py +175 -0
- loopx/cli_commands/starter_bootstrap.py +179 -0
- loopx/cli_commands/starter_bootstrap_registration.py +198 -0
- loopx/cli_commands/starter_runtime_idle.py +107 -0
- loopx/cli_commands/starter_scheduler.py +207 -0
- loopx/cli_commands/starter_session_runtime.py +152 -0
- loopx/cli_commands/starter_visible_common.py +54 -0
- loopx/cli_commands/starter_visible_driver.py +161 -0
- loopx/cli_commands/starter_visible_pilot.py +278 -0
- loopx/cli_commands/status.py +867 -0
- loopx/cli_commands/status_registration.py +239 -0
- loopx/cli_commands/summary_all.py +222 -0
- loopx/cli_commands/support_control.py +809 -0
- loopx/cli_commands/support_control_registry.py +68 -0
- loopx/cli_commands/support_control_supervisor.py +289 -0
- loopx/cli_commands/task_lease.py +306 -0
- loopx/cli_commands/terminal_bench_adapter.py +717 -0
- loopx/cli_commands/terminal_bench_environment_result.py +1246 -0
- loopx/cli_commands/todo.py +940 -0
- loopx/cli_commands/todo_argument_validation.py +572 -0
- loopx/cli_commands/todo_event.py +114 -0
- loopx/cli_commands/turn.py +804 -0
- loopx/cli_commands/version.py +46 -0
- loopx/cli_commands/worker_bridge.py +659 -0
- loopx/cli_rollout.py +314 -0
- loopx/codex_cli_goal_tui.py +672 -0
- loopx/codex_cli_probe.py +1530 -0
- loopx/codex_cli_probe_markdown.py +935 -0
- loopx/codex_cli_runtime_probe.py +733 -0
- loopx/codex_cli_scheduler.py +564 -0
- loopx/codex_goal_baseline.py +620 -0
- loopx/configuration_catalog.py +617 -0
- loopx/configure_goal.py +1375 -0
- loopx/contract.py +996 -0
- loopx/control_plane/__init__.py +71 -0
- loopx/control_plane/agents/__init__.py +1 -0
- loopx/control_plane/agents/agent_lane_recommendation.py +516 -0
- loopx/control_plane/agents/agent_scope.py +1578 -0
- loopx/control_plane/agents/agent_scope_frontier.py +60 -0
- loopx/control_plane/agents/capability_gate.py +531 -0
- loopx/control_plane/agents/identity.py +140 -0
- loopx/control_plane/agents/legacy_migration.py +169 -0
- loopx/control_plane/agents/management_projection.py +658 -0
- loopx/control_plane/agents/material_frontier.py +608 -0
- loopx/control_plane/agents/material_handoff.py +156 -0
- loopx/control_plane/agents/multi_agent/__init__.py +1 -0
- loopx/control_plane/agents/multi_agent/codex_executable.py +207 -0
- loopx/control_plane/agents/multi_agent/collective_round_ledger.py +387 -0
- loopx/control_plane/agents/multi_agent/contract.py +474 -0
- loopx/control_plane/agents/multi_agent/recipe.py +110 -0
- loopx/control_plane/agents/multi_agent/role_successor.py +297 -0
- loopx/control_plane/agents/multi_agent/runtime_scripts.py +426 -0
- loopx/control_plane/agents/multi_agent/visible_launch_policy.py +149 -0
- loopx/control_plane/agents/multi_agent/visible_wake_scheduler.py +392 -0
- loopx/control_plane/agents/profile.py +216 -0
- loopx/control_plane/agents/runtime_model.py +73 -0
- loopx/control_plane/agents/subagent_activity.py +164 -0
- loopx/control_plane/agents/supervisor.py +544 -0
- loopx/control_plane/agents/supervisor_events.py +462 -0
- loopx/control_plane/agents/supervisor_inject.py +204 -0
- loopx/control_plane/agents/work_mode.py +56 -0
- loopx/control_plane/agents/workspace_guard.py +364 -0
- loopx/control_plane/effect_program.py +644 -0
- loopx/control_plane/goals/__init__.py +1 -0
- loopx/control_plane/goals/active_state_event_projection.py +103 -0
- loopx/control_plane/goals/active_state_metadata.py +47 -0
- loopx/control_plane/goals/active_state_sections.py +58 -0
- loopx/control_plane/goals/configure_goal_service.py +354 -0
- loopx/control_plane/goals/contract_health.py +132 -0
- loopx/control_plane/goals/dreaming.py +152 -0
- loopx/control_plane/goals/global_registry_health.py +199 -0
- loopx/control_plane/goals/global_registry_shadow.py +33 -0
- loopx/control_plane/goals/goal_channel.py +34 -0
- loopx/control_plane/goals/goal_channel_projection.py +560 -0
- loopx/control_plane/goals/goal_frontier/__init__.py +1917 -0
- loopx/control_plane/goals/goal_frontier/ack_policy.py +149 -0
- loopx/control_plane/goals/goal_frontier/outcome_continuity.py +437 -0
- loopx/control_plane/goals/goal_frontier/replan_rules.py +210 -0
- loopx/control_plane/goals/goal_frontier/semantic_history.py +314 -0
- loopx/control_plane/goals/goal_frontier/terminal.py +180 -0
- loopx/control_plane/goals/goal_vision.py +443 -0
- loopx/control_plane/goals/goal_vision_policy.py +36 -0
- loopx/control_plane/goals/goal_vision_state.py +62 -0
- loopx/control_plane/goals/goal_vision_wait.py +290 -0
- loopx/control_plane/goals/path_resolution.py +20 -0
- loopx/control_plane/goals/start_contract.py +206 -0
- loopx/control_plane/goals/vision_checkpoint.py +92 -0
- loopx/control_plane/handoff/__init__.py +1 -0
- loopx/control_plane/handoff/cross_runtime_impl_review.py +311 -0
- loopx/control_plane/handoff/delivery_contract.py +161 -0
- loopx/control_plane/handoff/handoff_runs.py +71 -0
- loopx/control_plane/handoff/project_handoff.py +155 -0
- loopx/control_plane/handoff/review_batch.py +463 -0
- loopx/control_plane/handoff/review_packet_context.py +216 -0
- loopx/control_plane/heartbeat/agent.py +173 -0
- loopx/control_plane/heartbeat/budget.py +66 -0
- loopx/control_plane/heartbeat/builder.py +501 -0
- loopx/control_plane/heartbeat/host.py +64 -0
- loopx/control_plane/heartbeat/rules.py +68 -0
- loopx/control_plane/heartbeat/task_body.py +759 -0
- loopx/control_plane/heartbeat/visible_goal.py +86 -0
- loopx/control_plane/projects/__init__.py +1 -0
- loopx/control_plane/projects/contract.py +25 -0
- loopx/control_plane/projects/registry.py +663 -0
- loopx/control_plane/quota/__init__.py +1 -0
- loopx/control_plane/quota/cli_projection.py +704 -0
- loopx/control_plane/quota/decision_summary.py +431 -0
- loopx/control_plane/quota/effect_program.py +152 -0
- loopx/control_plane/quota/error_codes.py +19 -0
- loopx/control_plane/quota/goal_boundary.py +464 -0
- loopx/control_plane/quota/heartbeat_receipt.py +277 -0
- loopx/control_plane/quota/heartbeat_recommendation.py +718 -0
- loopx/control_plane/quota/host_poll_receipts.py +162 -0
- loopx/control_plane/quota/live_decision.py +142 -0
- loopx/control_plane/quota/monitor_poll.py +786 -0
- loopx/control_plane/quota/policy_constants.py +40 -0
- loopx/control_plane/quota/projection_repair.py +262 -0
- loopx/control_plane/quota/recent_runs.py +210 -0
- loopx/control_plane/quota/scheduler_ack.py +490 -0
- loopx/control_plane/quota/selected_todo_projection.py +139 -0
- loopx/control_plane/quota/settlement.py +437 -0
- loopx/control_plane/quota/settlement_cli.py +246 -0
- loopx/control_plane/quota/settlement_validation.py +64 -0
- loopx/control_plane/quota/settlement_workspace_causality.py +180 -0
- loopx/control_plane/quota/should_run.py +249 -0
- loopx/control_plane/quota/should_run_packet.py +1165 -0
- loopx/control_plane/quota/should_run_prepare.py +675 -0
- loopx/control_plane/quota/slot_accounting.py +1123 -0
- loopx/control_plane/quota/spend_sources.py +11 -0
- loopx/control_plane/quota/stall_repair.py +397 -0
- loopx/control_plane/quota/states.py +29 -0
- loopx/control_plane/quota/task_orchestration.py +448 -0
- loopx/control_plane/quota/task_orchestration_admission.py +497 -0
- loopx/control_plane/quota/turn_envelope.py +889 -0
- loopx/control_plane/quota/usage_summary.py +140 -0
- loopx/control_plane/reward_memory.py +43 -0
- loopx/control_plane/runtime/__init__.py +2 -0
- loopx/control_plane/runtime/active_user_assisted_pilot.py +275 -0
- loopx/control_plane/runtime/agent_scoped_evidence_log.py +435 -0
- loopx/control_plane/runtime/decision_freshness.py +203 -0
- loopx/control_plane/runtime/event_ledger.py +197 -0
- loopx/control_plane/runtime/event_store_migration_bridge.py +196 -0
- loopx/control_plane/runtime/goal_project_route.py +70 -0
- loopx/control_plane/runtime/local_state_write_correctness.py +242 -0
- loopx/control_plane/runtime/promotion_readiness.py +152 -0
- loopx/control_plane/runtime/public_safety.py +120 -0
- loopx/control_plane/runtime/run_artifacts.py +78 -0
- loopx/control_plane/runtime/run_compaction.py +397 -0
- loopx/control_plane/runtime/run_context_retention.py +241 -0
- loopx/control_plane/runtime/run_history.py +132 -0
- loopx/control_plane/runtime/run_index_duplicates.py +205 -0
- loopx/control_plane/runtime/run_index_rebuild.py +263 -0
- loopx/control_plane/runtime/run_ingest_health.py +336 -0
- loopx/control_plane/runtime/runtime_projection_route.py +624 -0
- loopx/control_plane/runtime/runtime_projection_writer.py +98 -0
- loopx/control_plane/runtime/session_runtime.py +339 -0
- loopx/control_plane/runtime/shared_runtime_material_projection.py +332 -0
- loopx/control_plane/runtime/shared_runtime_refresh_projection.py +183 -0
- loopx/control_plane/runtime/stale_latest_run.py +90 -0
- loopx/control_plane/runtime/status_classifications.py +49 -0
- loopx/control_plane/runtime/status_projection_cache.py +235 -0
- loopx/control_plane/runtime/stride_observation.py +144 -0
- loopx/control_plane/runtime/time.py +39 -0
- loopx/control_plane/runtime/trajectory_hygiene.py +149 -0
- loopx/control_plane/runtime/validation_command.py +69 -0
- loopx/control_plane/scheduler/__init__.py +1 -0
- loopx/control_plane/scheduler/ack.py +329 -0
- loopx/control_plane/scheduler/arbitration.py +188 -0
- loopx/control_plane/scheduler/automation_liveness.py +183 -0
- loopx/control_plane/scheduler/execution_context.py +555 -0
- loopx/control_plane/scheduler/external_evidence_observation.py +428 -0
- loopx/control_plane/scheduler/monitor_display.py +143 -0
- loopx/control_plane/scheduler/monitor_poll_policy.py +161 -0
- loopx/control_plane/scheduler/monitor_poll_writeback.py +351 -0
- loopx/control_plane/scheduler/monitor_target.py +64 -0
- loopx/control_plane/scheduler/monitor_todo.py +146 -0
- loopx/control_plane/scheduler/monitor_wait.py +237 -0
- loopx/control_plane/scheduler/scheduler_hint.py +1284 -0
- loopx/control_plane/scheduler/state.py +354 -0
- loopx/control_plane/scheduler/state_transition_rules.py +179 -0
- loopx/control_plane/scheduler/time.py +10 -0
- loopx/control_plane/settlement_driver.py +293 -0
- loopx/control_plane/status/__init__.py +6 -0
- loopx/control_plane/status/active_state_projection.py +105 -0
- loopx/control_plane/status/agent_lane_projection.py +375 -0
- loopx/control_plane/status/attention_projection.py +74 -0
- loopx/control_plane/status/autonomous_replan_projection.py +103 -0
- loopx/control_plane/status/collection.py +140 -0
- loopx/control_plane/status/contract_projection.py +31 -0
- loopx/control_plane/status/dreaming_projection.py +52 -0
- loopx/control_plane/status/goal_attention_projection.py +157 -0
- loopx/control_plane/status/lifecycle_projection.py +110 -0
- loopx/control_plane/status/monitor_display_projection.py +69 -0
- loopx/control_plane/status/registry_health_projection.py +75 -0
- loopx/control_plane/status/run_projection.py +70 -0
- loopx/control_plane/status/runtime_summaries.py +161 -0
- loopx/control_plane/testing/__init__.py +1 -0
- loopx/control_plane/testing/actual_default_model_behavior_portfolio.py +1371 -0
- loopx/control_plane/testing/canary_harness.py +182 -0
- loopx/control_plane/testing/capability_monitor_repair_tool_behavior.py +674 -0
- loopx/control_plane/testing/cli_output_budget.py +807 -0
- loopx/control_plane/testing/cli_output_differential.py +250 -0
- loopx/control_plane/testing/cli_output_semantics.py +87 -0
- loopx/control_plane/testing/control_plane_composition_scenarios.py +225 -0
- loopx/control_plane/testing/decision_replay.py +268 -0
- loopx/control_plane/testing/doubao_model_behavior_actor.py +559 -0
- loopx/control_plane/testing/model_behavior_corpus.py +344 -0
- loopx/control_plane/testing/model_behavior_qualification.py +769 -0
- loopx/control_plane/testing/model_behavior_retained_cases.py +235 -0
- loopx/control_plane/testing/model_tool_behavior.py +536 -0
- loopx/control_plane/testing/onboarding_model_behavior_qualification.py +642 -0
- loopx/control_plane/testing/quota_fixtures.py +208 -0
- loopx/control_plane/testing/quota_should_run_parity.py +57 -0
- loopx/control_plane/testing/release_commit_qualification.py +671 -0
- loopx/control_plane/testing/replan_semantic_action_behavior.py +1302 -0
- loopx/control_plane/testing/scoped_gate_successor_tool_behavior.py +527 -0
- loopx/control_plane/testing/selected_todo_tool_behavior.py +1002 -0
- loopx/control_plane/testing/terminal_settlement_tool_behavior.py +656 -0
- loopx/control_plane/todos/__init__.py +1 -0
- loopx/control_plane/todos/active_state_editing.py +296 -0
- loopx/control_plane/todos/active_state_todo_parser.py +138 -0
- loopx/control_plane/todos/active_state_todos.py +175 -0
- loopx/control_plane/todos/addition.py +103 -0
- loopx/control_plane/todos/claim_visibility.py +253 -0
- loopx/control_plane/todos/completed_archive.py +139 -0
- loopx/control_plane/todos/completion_fence.py +49 -0
- loopx/control_plane/todos/completion_policy.py +153 -0
- loopx/control_plane/todos/completion_validation.py +248 -0
- loopx/control_plane/todos/completion_validation_accountability.py +27 -0
- loopx/control_plane/todos/completion_validation_projection.py +57 -0
- loopx/control_plane/todos/contract.py +1476 -0
- loopx/control_plane/todos/decision_scope.py +554 -0
- loopx/control_plane/todos/deferred_resume.py +546 -0
- loopx/control_plane/todos/durable_completion.py +201 -0
- loopx/control_plane/todos/event_writeback.py +484 -0
- loopx/control_plane/todos/frontier_deadline.py +132 -0
- loopx/control_plane/todos/handoff_gate.py +283 -0
- loopx/control_plane/todos/handoff_mode.py +444 -0
- loopx/control_plane/todos/handoff_note.py +202 -0
- loopx/control_plane/todos/line_update.py +361 -0
- loopx/control_plane/todos/list_projection.py +205 -0
- loopx/control_plane/todos/markdown.py +199 -0
- loopx/control_plane/todos/monitor_metadata.py +88 -0
- loopx/control_plane/todos/mutation_authority.py +299 -0
- loopx/control_plane/todos/projection.py +655 -0
- loopx/control_plane/todos/quota_summary.py +1138 -0
- loopx/control_plane/todos/route_continuation.py +267 -0
- loopx/control_plane/todos/succession_warning.py +174 -0
- loopx/control_plane/todos/summary_item.py +223 -0
- loopx/control_plane/todos/text.py +30 -0
- loopx/control_plane/todos/todo_index.py +226 -0
- loopx/control_plane/todos/todo_summary.py +1458 -0
- loopx/control_plane/todos/unblock_resume.py +326 -0
- loopx/control_plane/todos/user_gate.py +263 -0
- loopx/control_plane/todos/write_hint.py +63 -0
- loopx/control_plane/todos/write_policy.py +135 -0
- loopx/control_plane/turn_driver/__init__.py +85 -0
- loopx/control_plane/turn_driver/codex_cli.py +502 -0
- loopx/control_plane/turn_driver/driver.py +355 -0
- loopx/control_plane/turn_driver/executor.py +1468 -0
- loopx/control_plane/turn_driver/loop_controller.py +669 -0
- loopx/control_plane/turn_driver/settlement.py +318 -0
- loopx/control_plane/turn_driver/transaction.py +375 -0
- loopx/control_plane/work_items/__init__.py +1 -0
- loopx/control_plane/work_items/attention_fields.py +56 -0
- loopx/control_plane/work_items/attention_item.py +77 -0
- loopx/control_plane/work_items/attention_queue.py +322 -0
- loopx/control_plane/work_items/attention_routing.py +213 -0
- loopx/control_plane/work_items/autonomous_candidates.py +135 -0
- loopx/control_plane/work_items/autonomous_replan_ack.py +276 -0
- loopx/control_plane/work_items/autonomous_replan_obligation.py +786 -0
- loopx/control_plane/work_items/backlog_hygiene.py +59 -0
- loopx/control_plane/work_items/capability_monitor_fallback.py +221 -0
- loopx/control_plane/work_items/delivery_batch_scale.py +66 -0
- loopx/control_plane/work_items/delivery_outcome.py +152 -0
- loopx/control_plane/work_items/delivery_signals.py +113 -0
- loopx/control_plane/work_items/execution_obligation.py +235 -0
- loopx/control_plane/work_items/goal_route_hint.py +320 -0
- loopx/control_plane/work_items/interaction_contract.py +1540 -0
- loopx/control_plane/work_items/issue_meta_surface.py +159 -0
- loopx/control_plane/work_items/lifecycle.py +139 -0
- loopx/control_plane/work_items/operator_inbox.py +266 -0
- loopx/control_plane/work_items/outcome_followthrough.py +69 -0
- loopx/control_plane/work_items/primary_action.py +326 -0
- loopx/control_plane/work_items/progress_observation.py +630 -0
- loopx/control_plane/work_items/project_asset.py +675 -0
- loopx/control_plane/work_items/repair_delta.py +693 -0
- loopx/control_plane/work_items/runtime_capability_reentry.py +168 -0
- loopx/control_plane/work_items/semantic_replan_writeback.py +177 -0
- loopx/control_plane/work_items/status_contract.py +49 -0
- loopx/control_plane/work_items/task_graph.py +1046 -0
- loopx/control_plane/work_items/task_lease.py +1254 -0
- loopx/control_plane/work_items/task_lease_settlement.py +422 -0
- loopx/control_plane/work_items/work_lane.py +510 -0
- loopx/control_plane/work_items/work_lane_context.py +161 -0
- loopx/demo.py +247 -0
- loopx/diagnose.py +633 -0
- loopx/doctor.py +1251 -0
- loopx/domain_packs/__init__.py +1 -0
- loopx/domain_packs/issue_fix.py +571 -0
- loopx/domain_packs/ml_experiment.py +854 -0
- loopx/domain_state.py +137 -0
- loopx/dreaming.py +706 -0
- loopx/entrypoint.py +16 -0
- loopx/event_sourced_state.py +981 -0
- loopx/execution_profile.py +286 -0
- loopx/experiments/__init__.py +1 -0
- loopx/experiments/planner_worker/__init__.py +1 -0
- loopx/experiments/planner_worker/contract.py +523 -0
- loopx/experiments/planner_worker/runtime.py +391 -0
- loopx/experiments/planner_worker/traex.py +461 -0
- loopx/explore_graph.py +11 -0
- loopx/extensions/__init__.py +1 -0
- loopx/extensions/bundled.py +28 -0
- loopx/extensions/execution_envelope.py +126 -0
- loopx/extensions/lark/__init__.py +11 -0
- loopx/extensions/lark/event_collector.py +478 -0
- loopx/extensions/lark/event_collector_runtime.py +506 -0
- loopx/extensions/lark/event_inbox.py +454 -0
- loopx/extensions/lark/extension.toml +88 -0
- loopx/extensions/lark/goal_channel.py +44 -0
- loopx/extensions/lark/goal_channel_contracts.py +388 -0
- loopx/extensions/lark/goal_channel_lifecycle.py +218 -0
- loopx/extensions/lark/goal_channel_runtime.py +792 -0
- loopx/extensions/lark/goal_channel_setup.py +805 -0
- loopx/extensions/lark/goal_channel_targets.py +215 -0
- loopx/extensions/lark/goal_channel_transport.py +281 -0
- loopx/extensions/lark/inbox_reactions.py +650 -0
- loopx/extensions/lark/inbox_reply.py +430 -0
- loopx/extensions/lark/presentation/__init__.py +11 -0
- loopx/extensions/lark/presentation/explore_results.py +2276 -0
- loopx/extensions/lark/presentation/explore_singleflight.py +127 -0
- loopx/extensions/lark/presentation/explore_source_guard.py +121 -0
- loopx/extensions/lark/presentation/explore_stage_document.py +703 -0
- loopx/extensions/lark/presentation/explore_visual_integrity.py +122 -0
- loopx/extensions/lark/presentation/explore_visual_readback.py +452 -0
- loopx/extensions/lark/presentation/explore_visual_styles.py +156 -0
- loopx/extensions/lark/presentation/issue_fix_surface.py +612 -0
- loopx/extensions/lark/presentation/kanban.py +2791 -0
- loopx/extensions/lark/presentation/message_card.py +112 -0
- loopx/extensions/lark/presentation/periodic_report.py +261 -0
- loopx/extensions/lark/presentation/projection_rows.py +600 -0
- loopx/extensions/lark/presentation/record_io.py +95 -0
- loopx/extensions/lark/presentation/sync_receipt.py +145 -0
- loopx/extensions/lark/private_json.py +40 -0
- loopx/extensions/lark/provider.py +86 -0
- loopx/extensions/lark/reviewer_notification.py +604 -0
- loopx/extensions/manifest.py +385 -0
- loopx/extensions/openviking_periodic_report/__init__.py +17 -0
- loopx/extensions/openviking_periodic_report/activation.py +173 -0
- loopx/extensions/openviking_periodic_report/extension.toml +17 -0
- loopx/extensions/openviking_periodic_report/provider.py +355 -0
- loopx/extensions/openviking_periodic_report/sink.py +117 -0
- loopx/extensions/openviking_semantic_preference/__init__.py +5 -0
- loopx/extensions/openviking_semantic_preference/extension.toml +16 -0
- loopx/extensions/openviking_semantic_preference/history_export.py +484 -0
- loopx/extensions/openviking_semantic_preference/project_peer.py +68 -0
- loopx/extensions/openviking_semantic_preference/provider.py +312 -0
- loopx/extensions/presentation.py +979 -0
- loopx/extensions/process_runtime.py +204 -0
- loopx/extensions/readiness.py +168 -0
- loopx/extensions/runtime.py +931 -0
- loopx/extensions/scaffold.py +335 -0
- loopx/feedback.py +581 -0
- loopx/file_lock.py +382 -0
- loopx/global_registry.py +842 -0
- loopx/global_risks.py +970 -0
- loopx/global_todos.py +568 -0
- loopx/handoff_budget.py +28 -0
- loopx/heartbeat_prequota.py +80 -0
- loopx/heartbeat_prompt.py +159 -0
- loopx/help_surface.py +516 -0
- loopx/history.py +1507 -0
- loopx/host_loop_activation.py +1311 -0
- loopx/host_mode_planner.py +991 -0
- loopx/install_contract.py +1 -0
- loopx/interface_budget.py +196 -0
- loopx/long_task_cadence.py +208 -0
- loopx/materials.py +185 -0
- loopx/ml_experiment.py +3 -0
- loopx/onboarding.py +214 -0
- loopx/opencode2_goal_mode/README.md +81 -0
- loopx/opencode2_goal_mode/__init__.py +9 -0
- loopx/opencode2_goal_mode/opencode2-goal-worker.mjs +1018 -0
- loopx/opencode_goal_mode/README.md +99 -0
- loopx/opencode_goal_mode/__init__.py +13 -0
- loopx/opencode_goal_mode/goal-bridge-runtime.mjs +858 -0
- loopx/opencode_goal_mode/loopx-goal.js +8 -0
- loopx/operator_gate.py +420 -0
- loopx/orchestration.py +127 -0
- loopx/paths.py +59 -0
- loopx/pi_goal_mode/README.md +67 -0
- loopx/pi_goal_mode/__init__.py +13 -0
- loopx/pi_goal_mode/loopx-goal.ts +254 -0
- loopx/pi_goal_mode/pi-goal-loop-runtime.mjs +574 -0
- loopx/pr_review.py +1206 -0
- loopx/presentation/__init__.py +1 -0
- loopx/presentation/explore_views.py +1334 -0
- loopx/presentation/markdown.py +61 -0
- loopx/presentation/projection_source_reconcile.py +140 -0
- loopx/presentation/public_safety.py +42 -0
- loopx/presentation/renderers/__init__.py +17 -0
- loopx/presentation/renderers/goal_channel_html.py +269 -0
- loopx/presentation/renderers/periodic_report_html.py +786 -0
- loopx/presentation/renderers/periodic_report_markdown.py +184 -0
- loopx/presentation/renderers/quota_event_markdown.py +116 -0
- loopx/presentation/renderers/quota_markdown.py +1112 -0
- loopx/presentation/renderers/status_markdown.py +1570 -0
- loopx/presentation/renderers/trajectory_hygiene_markdown.py +39 -0
- loopx/presentation/renderers/turn_envelope_markdown.py +33 -0
- loopx/presentation/sinks/__init__.py +5 -0
- loopx/presentation/sinks/openviking_periodic_report.py +7 -0
- loopx/presentation/static_site.py +691 -0
- loopx/presets.py +369 -0
- loopx/project_alias.py +217 -0
- loopx/project_map.py +589 -0
- loopx/project_prompt.py +1153 -0
- loopx/project_skill_cli.py +125 -0
- loopx/project_skill_delivery.py +470 -0
- loopx/project_uninstall.py +462 -0
- loopx/promotion_gate.py +197 -0
- loopx/quota.py +1197 -0
- loopx/ready_score.py +413 -0
- loopx/registry.py +621 -0
- loopx/registry_writability.py +64 -0
- loopx/release_candidate.py +148 -0
- loopx/release_manifest.py +316 -0
- loopx/repository_identity.py +100 -0
- loopx/review_packet.py +1024 -0
- loopx/rollout_event_log.py +505 -0
- loopx/runtime.py +112 -0
- loopx/self_update.py +750 -0
- loopx/session_runtime.py +418 -0
- loopx/skill_install_readback.py +500 -0
- loopx/slash_command_install.py +1393 -0
- loopx/slash_commands.py +264 -0
- loopx/state_backup.py +573 -0
- loopx/state_migration.py +350 -0
- loopx/state_projection.py +809 -0
- loopx/state_refresh.py +1416 -0
- loopx/status.py +1383 -0
- loopx/status_server.py +935 -0
- loopx/summary_all.py +725 -0
- loopx/terminal_bench_agent.py +2056 -0
- loopx/thread_agent_binding.py +408 -0
- loopx/todo_followups.py +168 -0
- loopx/todo_suggestion_prompt.py +204 -0
- loopx/todos.py +2229 -0
- loopx/turn_identity.py +17 -0
- loopx/upgrade.py +1083 -0
- loopx/visible_governance.py +667 -0
- loopx/visible_multi_agent_launcher.py +1253 -0
- loopx/visible_multi_agent_tmux.py +429 -0
- loopx/worker_bridge.py +1574 -0
- loopx-0.4.8.dist-info/METADATA +708 -0
- loopx-0.4.8.dist-info/RECORD +811 -0
- loopx-0.4.8.dist-info/WHEEL +5 -0
- loopx-0.4.8.dist-info/entry_points.txt +5 -0
- loopx-0.4.8.dist-info/licenses/LICENSE +202 -0
- loopx-0.4.8.dist-info/licenses/LICENSE-MIT +21 -0
- loopx-0.4.8.dist-info/licenses/NOTICE +6 -0
- loopx-0.4.8.dist-info/top_level.txt +1 -0
loopx/contract.py
ADDED
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import os
|
|
5
|
+
import re
|
|
6
|
+
import subprocess
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from .agent_registry import registered_agent_ids_for_goal
|
|
11
|
+
from .control_plane.goals.contract_health import (
|
|
12
|
+
contract_error_diagnostic,
|
|
13
|
+
contract_error_views,
|
|
14
|
+
project_contract_health_for_goal,
|
|
15
|
+
)
|
|
16
|
+
from .control_plane.runtime.run_index_duplicates import (
|
|
17
|
+
classify_index_duplicate_records,
|
|
18
|
+
index_identity,
|
|
19
|
+
)
|
|
20
|
+
from .control_plane.todos.active_state_editing import COMPLETED_WORK_ARCHIVE_HEADING
|
|
21
|
+
from .history import collect_history, load_registry
|
|
22
|
+
from .paths import DEFAULT_RUNTIME_ROOT, rel_or_abs, resolve_runtime_root
|
|
23
|
+
from .registry import inspect_registry, inspect_registry_boundary, registry_goals, resolve_state_file
|
|
24
|
+
from .state_projection import state_projection_gap_warning
|
|
25
|
+
from .control_plane.todos.contract import (
|
|
26
|
+
TODO_STATUS_DEFERRED,
|
|
27
|
+
TODO_STATUS_DONE,
|
|
28
|
+
TODO_METADATA_PATTERN,
|
|
29
|
+
TODO_TASK_CLASS_USER_ACTION,
|
|
30
|
+
TODO_TASK_CLASS_USER_GATE,
|
|
31
|
+
TODO_TASK_PATTERN,
|
|
32
|
+
decode_metadata_value,
|
|
33
|
+
normalize_todo_bound_agent,
|
|
34
|
+
normalize_todo_claimed_by,
|
|
35
|
+
normalize_todo_excluded_agents,
|
|
36
|
+
normalize_todo_goal_bound,
|
|
37
|
+
normalize_removed_todo_continuation_policy,
|
|
38
|
+
normalize_todo_status,
|
|
39
|
+
parse_todo_metadata_line,
|
|
40
|
+
parse_todo_metadata_tokens,
|
|
41
|
+
require_todo_excluded_agents,
|
|
42
|
+
todo_status_from_marker,
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
LEAK_PATTERNS = {
|
|
47
|
+
"private_doc_url": re.compile(
|
|
48
|
+
"|".join(["la" + "rk" + "office", "docs" + r"\." + "internal"]),
|
|
49
|
+
re.I,
|
|
50
|
+
),
|
|
51
|
+
"credential": re.compile(
|
|
52
|
+
"|".join(
|
|
53
|
+
[
|
|
54
|
+
"Bear" + "er" + r"\s+[A-Za-z0-9._-]+",
|
|
55
|
+
"AK" + "IA" + r"[0-9A-Z]{16}",
|
|
56
|
+
r"(?<![A-Za-z0-9_])" + "tok" + "en=",
|
|
57
|
+
r"(?<![A-Za-z0-9_])" + "pass" + "word=",
|
|
58
|
+
"Author" + "ization:",
|
|
59
|
+
]
|
|
60
|
+
),
|
|
61
|
+
re.I,
|
|
62
|
+
),
|
|
63
|
+
"local_private_path": re.compile(
|
|
64
|
+
"(" + "/" + "Users" + "/" + r"[^/\s]+/(?:Documents|code" + "-" + r"reading)|" + "/ext" + "_data/" + ")"
|
|
65
|
+
),
|
|
66
|
+
"internal_task_id": re.compile(r"\bt-" + r"20\d{12}-[a-z0-9]+\b"),
|
|
67
|
+
"private_ip": re.compile(r"\b10\.\d+\.\d+\.\d+\b|\b172\.(?:1[6-9]|2\d|3[01])\.\d+\.\d+\b|\b192\.168\.\d+\.\d+\b"),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
CREDENTIAL_KEYWORD_PATTERN = re.compile(
|
|
71
|
+
"|".join(
|
|
72
|
+
[
|
|
73
|
+
"Bear" + "er" + r"\s+",
|
|
74
|
+
r"(?<![A-Za-z0-9_])" + "tok" + "en=",
|
|
75
|
+
r"(?<![A-Za-z0-9_])" + "pass" + "word=",
|
|
76
|
+
"Author" + "ization:" + r"\s*",
|
|
77
|
+
]
|
|
78
|
+
),
|
|
79
|
+
re.I,
|
|
80
|
+
)
|
|
81
|
+
CREDENTIAL_BEARER_KEYWORD_PATTERN = re.compile("Bear" + "er" + r"\s+", re.I)
|
|
82
|
+
CREDENTIAL_ENVIRONMENT_REFERENCE_PATTERN = re.compile(
|
|
83
|
+
"|".join(
|
|
84
|
+
[
|
|
85
|
+
r"\$\{?[A-Za-z_]",
|
|
86
|
+
r"\$\(",
|
|
87
|
+
r"%[A-Za-z_][A-Za-z0-9_]*%",
|
|
88
|
+
r"os\.environ",
|
|
89
|
+
r"os\.getenv",
|
|
90
|
+
r"process\.env",
|
|
91
|
+
r"Deno\.env\.get",
|
|
92
|
+
r"System\.getenv",
|
|
93
|
+
r"(?<![A-Za-z0-9_])getenv\(",
|
|
94
|
+
]
|
|
95
|
+
)
|
|
96
|
+
)
|
|
97
|
+
CREDENTIAL_PLACEHOLDER_PATTERN = re.compile(
|
|
98
|
+
r"<[^>]{1,64}>|\{\{|example|dummy|placeholder|changeme|redacted|your[-_]",
|
|
99
|
+
re.I,
|
|
100
|
+
)
|
|
101
|
+
CREDENTIAL_HIGH_ENTROPY_VALUE_PATTERN = re.compile(r"[A-Za-z0-9._-]{20,}")
|
|
102
|
+
CREDENTIAL_VARIABLE_REFERENCE_PATTERN = re.compile(
|
|
103
|
+
r"[A-Za-z_][A-Za-z0-9_]*(?:\.[A-Za-z_][A-Za-z0-9_]*)*\s*[,)\]}]"
|
|
104
|
+
)
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
def _credential_match_is_reference(line: str, match: re.Match[str]) -> bool:
|
|
108
|
+
value = line[match.start() :]
|
|
109
|
+
last_keyword: str | None = None
|
|
110
|
+
while True:
|
|
111
|
+
keyword = CREDENTIAL_KEYWORD_PATTERN.match(value)
|
|
112
|
+
if keyword is None:
|
|
113
|
+
break
|
|
114
|
+
last_keyword = keyword.group(0)
|
|
115
|
+
value = value[keyword.end() :].lstrip(" \t\"'`")
|
|
116
|
+
if last_keyword is None:
|
|
117
|
+
return bool(CREDENTIAL_PLACEHOLDER_PATTERN.search(match.group(0)))
|
|
118
|
+
if not value:
|
|
119
|
+
return True
|
|
120
|
+
if CREDENTIAL_ENVIRONMENT_REFERENCE_PATTERN.match(value):
|
|
121
|
+
return True
|
|
122
|
+
if CREDENTIAL_PLACEHOLDER_PATTERN.match(value):
|
|
123
|
+
return True
|
|
124
|
+
if CREDENTIAL_HIGH_ENTROPY_VALUE_PATTERN.match(value):
|
|
125
|
+
return False
|
|
126
|
+
if CREDENTIAL_BEARER_KEYWORD_PATTERN.fullmatch(last_keyword):
|
|
127
|
+
return True
|
|
128
|
+
return bool(CREDENTIAL_VARIABLE_REFERENCE_PATTERN.match(value))
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
def _credential_hits_are_all_references(line: str) -> bool:
|
|
132
|
+
matches = list(LEAK_PATTERNS["credential"].finditer(line))
|
|
133
|
+
if not matches:
|
|
134
|
+
return False
|
|
135
|
+
return all(_credential_match_is_reference(line, match) for match in matches)
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
DEFAULT_SCAN_SUFFIXES = {".md", ".py", ".toml", ".json", ".yaml", ".yml", ".sh"}
|
|
139
|
+
DEFAULT_SKIP_DIRS = {
|
|
140
|
+
".git",
|
|
141
|
+
".goal-harness",
|
|
142
|
+
".loopx",
|
|
143
|
+
".goal-wrapper.local",
|
|
144
|
+
".local",
|
|
145
|
+
".venv",
|
|
146
|
+
"__pycache__",
|
|
147
|
+
".pytest_cache",
|
|
148
|
+
".ruff_cache",
|
|
149
|
+
"build",
|
|
150
|
+
"dist",
|
|
151
|
+
"node_modules",
|
|
152
|
+
"runtime",
|
|
153
|
+
}
|
|
154
|
+
LOCAL_PRIVATE_STATE_PARTS = {
|
|
155
|
+
".codex",
|
|
156
|
+
".goal-harness",
|
|
157
|
+
".goal-wrapper.local",
|
|
158
|
+
".local",
|
|
159
|
+
".loopx",
|
|
160
|
+
"logs",
|
|
161
|
+
"runtime",
|
|
162
|
+
}
|
|
163
|
+
LOCAL_PRIVATE_STATE_FILE_NAMES = {"ACTIVE_GOAL_STATE.md", "ACTIVE_GOAL_STATE.md.lock"}
|
|
164
|
+
TERMINAL_TODO_STATUSES = {TODO_STATUS_DONE, TODO_STATUS_DEFERRED, "completed", "closed", "archived"}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def _git_probe(path: Path) -> dict[str, Any]:
|
|
168
|
+
path = path.resolve()
|
|
169
|
+
target = path if path.is_dir() else path.parent
|
|
170
|
+
try:
|
|
171
|
+
root = subprocess.run(
|
|
172
|
+
["git", "-C", str(target), "rev-parse", "--show-toplevel"],
|
|
173
|
+
text=True,
|
|
174
|
+
encoding="utf-8",
|
|
175
|
+
errors="replace",
|
|
176
|
+
capture_output=True,
|
|
177
|
+
check=True,
|
|
178
|
+
).stdout.strip()
|
|
179
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
180
|
+
return {"inside_worktree": False, "tracked": False, "ignored": False}
|
|
181
|
+
|
|
182
|
+
repo_root = Path(root).resolve()
|
|
183
|
+
try:
|
|
184
|
+
rel_path = str(path.relative_to(repo_root))
|
|
185
|
+
except ValueError:
|
|
186
|
+
rel_path = str(path)
|
|
187
|
+
tracked = (
|
|
188
|
+
subprocess.run(
|
|
189
|
+
["git", "-C", str(repo_root), "ls-files", "--error-unmatch", "--", rel_path],
|
|
190
|
+
text=True,
|
|
191
|
+
encoding="utf-8",
|
|
192
|
+
errors="replace",
|
|
193
|
+
capture_output=True,
|
|
194
|
+
check=False,
|
|
195
|
+
).returncode
|
|
196
|
+
== 0
|
|
197
|
+
)
|
|
198
|
+
ignored = (
|
|
199
|
+
subprocess.run(
|
|
200
|
+
["git", "-C", str(repo_root), "check-ignore", "-q", "--", rel_path],
|
|
201
|
+
text=True,
|
|
202
|
+
encoding="utf-8",
|
|
203
|
+
errors="replace",
|
|
204
|
+
capture_output=True,
|
|
205
|
+
check=False,
|
|
206
|
+
).returncode
|
|
207
|
+
== 0
|
|
208
|
+
)
|
|
209
|
+
return {
|
|
210
|
+
"inside_worktree": True,
|
|
211
|
+
"root": str(repo_root),
|
|
212
|
+
"tracked": tracked,
|
|
213
|
+
"ignored": ignored,
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
217
|
+
def _is_local_private_state_path(path: Path) -> bool:
|
|
218
|
+
parts = set(path.parts)
|
|
219
|
+
return bool(parts & LOCAL_PRIVATE_STATE_PARTS) or path.name in LOCAL_PRIVATE_STATE_FILE_NAMES
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
def _public_boundary_policy(registry: dict[str, Any]) -> dict[str, str]:
|
|
223
|
+
policy = registry.get("public_boundary") if isinstance(registry, dict) else None
|
|
224
|
+
if not isinstance(policy, dict):
|
|
225
|
+
policy = registry.get("privacy") if isinstance(registry, dict) else None
|
|
226
|
+
if not isinstance(policy, dict):
|
|
227
|
+
policy = {}
|
|
228
|
+
|
|
229
|
+
tracked_private_doc_urls = "block"
|
|
230
|
+
raw_mode = (
|
|
231
|
+
policy.get("tracked_private_doc_urls")
|
|
232
|
+
or policy.get("private_doc_urls_in_tracked_files")
|
|
233
|
+
)
|
|
234
|
+
if str(raw_mode).lower() == "allow" or policy.get("allow_tracked_private_doc_urls") is True:
|
|
235
|
+
tracked_private_doc_urls = "allow"
|
|
236
|
+
|
|
237
|
+
return {
|
|
238
|
+
"schema_version": "loopx_public_boundary_policy_v0",
|
|
239
|
+
"tracked_private_doc_urls": tracked_private_doc_urls,
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def _hit_allowed_by_policy(name: str, git: dict[str, Any], policy: dict[str, str]) -> bool:
|
|
244
|
+
if name != "private_doc_url":
|
|
245
|
+
return False
|
|
246
|
+
if not git.get("tracked"):
|
|
247
|
+
return False
|
|
248
|
+
return policy.get("tracked_private_doc_urls") == "allow"
|
|
249
|
+
|
|
250
|
+
|
|
251
|
+
def _index_duplicate_summary(index_path: Path) -> dict[str, Any]:
|
|
252
|
+
groups: dict[tuple[str, str, str], list[dict[str, Any]]] = {}
|
|
253
|
+
if not index_path.exists():
|
|
254
|
+
return {
|
|
255
|
+
"duplicate_rows": 0,
|
|
256
|
+
"reward_overlay_rows": 0,
|
|
257
|
+
"structured_artifact_bundle_rows": 0,
|
|
258
|
+
"unexpected_duplicate_rows": 0,
|
|
259
|
+
"repairable_duplicate_rows": 0,
|
|
260
|
+
"artifact_identity_collision_rows": 0,
|
|
261
|
+
"artifact_identity_collision_groups": 0,
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
with index_path.open(encoding="utf-8") as f:
|
|
265
|
+
for line in f:
|
|
266
|
+
if not line.strip():
|
|
267
|
+
continue
|
|
268
|
+
try:
|
|
269
|
+
item = json.loads(line)
|
|
270
|
+
except json.JSONDecodeError:
|
|
271
|
+
continue
|
|
272
|
+
if not isinstance(item, dict):
|
|
273
|
+
continue
|
|
274
|
+
groups.setdefault(index_identity(item), []).append(item)
|
|
275
|
+
|
|
276
|
+
reward_overlay_rows = 0
|
|
277
|
+
structured_artifact_bundle_rows = 0
|
|
278
|
+
unexpected_duplicate_rows = 0
|
|
279
|
+
repairable_duplicate_rows = 0
|
|
280
|
+
artifact_identity_collision_rows = 0
|
|
281
|
+
artifact_identity_collision_groups = 0
|
|
282
|
+
for records in groups.values():
|
|
283
|
+
if len(records) <= 1:
|
|
284
|
+
continue
|
|
285
|
+
duplicate_rows = len(records) - 1
|
|
286
|
+
duplicate_classification = classify_index_duplicate_records(records)
|
|
287
|
+
duplicate_kind = duplicate_classification.get("duplicate_kind")
|
|
288
|
+
if duplicate_kind == "reward_overlay":
|
|
289
|
+
reward_overlay_rows += duplicate_rows
|
|
290
|
+
elif duplicate_kind == "structured_artifact_bundle":
|
|
291
|
+
structured_artifact_bundle_rows += duplicate_rows
|
|
292
|
+
elif duplicate_classification.get("repairable"):
|
|
293
|
+
unexpected_duplicate_rows += duplicate_rows
|
|
294
|
+
repairable_duplicate_rows += duplicate_rows
|
|
295
|
+
else:
|
|
296
|
+
unexpected_duplicate_rows += duplicate_rows
|
|
297
|
+
artifact_identity_collision_rows += duplicate_rows
|
|
298
|
+
artifact_identity_collision_groups += 1
|
|
299
|
+
|
|
300
|
+
return {
|
|
301
|
+
"duplicate_rows": reward_overlay_rows + structured_artifact_bundle_rows + unexpected_duplicate_rows,
|
|
302
|
+
"reward_overlay_rows": reward_overlay_rows,
|
|
303
|
+
"structured_artifact_bundle_rows": structured_artifact_bundle_rows,
|
|
304
|
+
"unexpected_duplicate_rows": unexpected_duplicate_rows,
|
|
305
|
+
"repairable_duplicate_rows": repairable_duplicate_rows,
|
|
306
|
+
"artifact_identity_collision_rows": artifact_identity_collision_rows,
|
|
307
|
+
"artifact_identity_collision_groups": artifact_identity_collision_groups,
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _index_duplicate_warning(
|
|
312
|
+
goal_id: object,
|
|
313
|
+
raw: int,
|
|
314
|
+
unique: int,
|
|
315
|
+
duplicate_summary: dict[str, Any] | None = None,
|
|
316
|
+
) -> str:
|
|
317
|
+
safe_goal_id = str(goal_id)
|
|
318
|
+
duplicate_summary = duplicate_summary or {}
|
|
319
|
+
detail_parts = []
|
|
320
|
+
unexpected_rows = int(duplicate_summary.get("unexpected_duplicate_rows") or 0)
|
|
321
|
+
repairable_rows = int(duplicate_summary.get("repairable_duplicate_rows") or 0)
|
|
322
|
+
artifact_collision_rows = int(duplicate_summary.get("artifact_identity_collision_rows") or 0)
|
|
323
|
+
artifact_collision_groups = int(duplicate_summary.get("artifact_identity_collision_groups") or 0)
|
|
324
|
+
reward_overlay_rows = int(duplicate_summary.get("reward_overlay_rows") or 0)
|
|
325
|
+
structured_artifact_bundle_rows = int(duplicate_summary.get("structured_artifact_bundle_rows") or 0)
|
|
326
|
+
if unexpected_rows:
|
|
327
|
+
detail_parts.append(f"unexpected={unexpected_rows}")
|
|
328
|
+
if repairable_rows:
|
|
329
|
+
detail_parts.append(f"auto_repairable={repairable_rows}")
|
|
330
|
+
if artifact_collision_groups:
|
|
331
|
+
detail_parts.append(f"artifact_identity_collisions={artifact_collision_groups}")
|
|
332
|
+
if artifact_collision_rows:
|
|
333
|
+
detail_parts.append(f"artifact_collision_rows={artifact_collision_rows}")
|
|
334
|
+
if reward_overlay_rows:
|
|
335
|
+
detail_parts.append(f"reward_overlays={reward_overlay_rows}")
|
|
336
|
+
if structured_artifact_bundle_rows:
|
|
337
|
+
detail_parts.append(f"structured_artifact_bundles={structured_artifact_bundle_rows}")
|
|
338
|
+
if not detail_parts and raw > unique:
|
|
339
|
+
detail_parts.append(f"duplicates={raw - unique}")
|
|
340
|
+
detail = f" {' '.join(detail_parts)}" if detail_parts else ""
|
|
341
|
+
inspect_command = f"`loopx history --goal-id {safe_goal_id} inspect-index-duplicates`"
|
|
342
|
+
repair_command = f"`loopx history --goal-id {safe_goal_id} repair-index-duplicates`"
|
|
343
|
+
if artifact_collision_rows:
|
|
344
|
+
action = (
|
|
345
|
+
f"inspect with {inspect_command}; artifact identity collisions need reviewed merge semantics"
|
|
346
|
+
)
|
|
347
|
+
if repairable_rows:
|
|
348
|
+
action += f"; preview safe repair for auto-repairable rows with {repair_command}"
|
|
349
|
+
else:
|
|
350
|
+
action = f"inspect with {inspect_command}; preview repair with {repair_command}"
|
|
351
|
+
return f"{safe_goal_id}: duplicate index rows raw={raw} unique={unique}{detail}; {action}"
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
def _active_state_todo_contract_diagnostics(
|
|
355
|
+
registry: dict[str, Any],
|
|
356
|
+
*,
|
|
357
|
+
goal_id_filter: str | None = None,
|
|
358
|
+
) -> tuple[list[dict[str, Any]], int]:
|
|
359
|
+
diagnostics: list[dict[str, Any]] = []
|
|
360
|
+
checked = 0
|
|
361
|
+
for goal in registry_goals(registry):
|
|
362
|
+
goal_id = str(goal.get("id") or "")
|
|
363
|
+
if goal_id_filter and goal_id != goal_id_filter:
|
|
364
|
+
continue
|
|
365
|
+
|
|
366
|
+
def add_error(code: str, message: str) -> None:
|
|
367
|
+
diagnostics.append(
|
|
368
|
+
contract_error_diagnostic(
|
|
369
|
+
code=code,
|
|
370
|
+
message=message,
|
|
371
|
+
goal_id=goal_id,
|
|
372
|
+
)
|
|
373
|
+
)
|
|
374
|
+
|
|
375
|
+
registered_agents = registered_agent_ids_for_goal(goal)
|
|
376
|
+
repo_text = str(goal.get("repo") or "").strip()
|
|
377
|
+
if not repo_text:
|
|
378
|
+
continue
|
|
379
|
+
state_file = resolve_state_file(Path(repo_text).expanduser(), goal.get("state_file"))
|
|
380
|
+
if not state_file or not state_file.exists():
|
|
381
|
+
continue
|
|
382
|
+
try:
|
|
383
|
+
lines = state_file.read_text(encoding="utf-8").splitlines()
|
|
384
|
+
except OSError as exc:
|
|
385
|
+
add_error(
|
|
386
|
+
"active_state_read_failed",
|
|
387
|
+
f"{goal_id}: cannot read active state for todo contract check: {exc}",
|
|
388
|
+
)
|
|
389
|
+
continue
|
|
390
|
+
|
|
391
|
+
role: str | None = None
|
|
392
|
+
in_completed_work_archive = False
|
|
393
|
+
index = 0
|
|
394
|
+
while index < len(lines):
|
|
395
|
+
line = lines[index]
|
|
396
|
+
if line.startswith("## "):
|
|
397
|
+
heading_text = line.lstrip("#").strip()
|
|
398
|
+
heading = heading_text.lower()
|
|
399
|
+
in_completed_work_archive = (
|
|
400
|
+
heading_text.casefold() == COMPLETED_WORK_ARCHIVE_HEADING.casefold()
|
|
401
|
+
)
|
|
402
|
+
if "user todo" in heading or "owner review" in heading:
|
|
403
|
+
role = "user"
|
|
404
|
+
elif "agent todo" in heading:
|
|
405
|
+
role = "agent"
|
|
406
|
+
else:
|
|
407
|
+
role = None
|
|
408
|
+
index += 1
|
|
409
|
+
continue
|
|
410
|
+
match = TODO_TASK_PATTERN.match(line)
|
|
411
|
+
if not match:
|
|
412
|
+
index += 1
|
|
413
|
+
continue
|
|
414
|
+
marker, text = match.groups()
|
|
415
|
+
metadata: dict[str, Any] = {}
|
|
416
|
+
malformed_excluded_agents = False
|
|
417
|
+
malformed_status = False
|
|
418
|
+
next_index = index + 1
|
|
419
|
+
while next_index < len(lines):
|
|
420
|
+
if lines[next_index].startswith("## ") or TODO_TASK_PATTERN.match(lines[next_index]):
|
|
421
|
+
break
|
|
422
|
+
raw_line = lines[next_index]
|
|
423
|
+
raw_metadata = parse_todo_metadata_tokens(raw_line)
|
|
424
|
+
metadata_match = TODO_METADATA_PATTERN.match(raw_line)
|
|
425
|
+
if metadata_match:
|
|
426
|
+
for raw_field in metadata_match.group("body").split():
|
|
427
|
+
if not raw_field.startswith("status="):
|
|
428
|
+
continue
|
|
429
|
+
raw_status = decode_metadata_value(raw_field.split("=", 1)[1])
|
|
430
|
+
if normalize_todo_status(raw_status) is None:
|
|
431
|
+
malformed_status = True
|
|
432
|
+
for key, value in raw_metadata or []:
|
|
433
|
+
if key == "status" and normalize_todo_status(value) is None:
|
|
434
|
+
malformed_status = True
|
|
435
|
+
if key not in {"excluded_agent", "excluded_agents"}:
|
|
436
|
+
continue
|
|
437
|
+
try:
|
|
438
|
+
require_todo_excluded_agents(value)
|
|
439
|
+
except ValueError:
|
|
440
|
+
malformed_excluded_agents = True
|
|
441
|
+
parsed = parse_todo_metadata_line(raw_line)
|
|
442
|
+
if parsed:
|
|
443
|
+
metadata.update(parsed)
|
|
444
|
+
next_index += 1
|
|
445
|
+
removed_continuation_policy = normalize_removed_todo_continuation_policy(
|
|
446
|
+
metadata.get("removed_continuation_policy")
|
|
447
|
+
)
|
|
448
|
+
status = str(metadata.get("status") or todo_status_from_marker(marker) or "").lower()
|
|
449
|
+
task_class = str(metadata.get("task_class") or "")
|
|
450
|
+
todo_id = metadata.get("todo_id") or f"line:{index + 1}"
|
|
451
|
+
if malformed_excluded_agents:
|
|
452
|
+
add_error(
|
|
453
|
+
"todo_excluded_agents_invalid",
|
|
454
|
+
f"{goal_id}: todo {todo_id} has malformed excluded_agents metadata; "
|
|
455
|
+
"replace it with --excluded-agent <registered-agent> or remove it "
|
|
456
|
+
"with --clear-excluded-agents",
|
|
457
|
+
)
|
|
458
|
+
if malformed_status:
|
|
459
|
+
add_error(
|
|
460
|
+
"todo_status_invalid",
|
|
461
|
+
f"{goal_id}: todo {todo_id} has malformed status metadata; "
|
|
462
|
+
"replace it with status=open, status=done, status=blocked, or "
|
|
463
|
+
"status=deferred",
|
|
464
|
+
)
|
|
465
|
+
if role == "agent" and removed_continuation_policy:
|
|
466
|
+
add_error(
|
|
467
|
+
"agent_todo_removed_continuation_policy",
|
|
468
|
+
f"{goal_id}: agent todo {todo_id} uses removed continuation_policy="
|
|
469
|
+
f"{removed_continuation_policy}; use continuation_policy=independent_handoff "
|
|
470
|
+
"with an explicit review action_kind and excluded_agents=<author> only when "
|
|
471
|
+
"executor separation is required",
|
|
472
|
+
)
|
|
473
|
+
blocks_agent = metadata.get("blocks_agent")
|
|
474
|
+
if role == "agent" and blocks_agent:
|
|
475
|
+
add_error(
|
|
476
|
+
"agent_todo_blocks_agent_invalid",
|
|
477
|
+
f"{goal_id}: agent todo {todo_id} uses removed blocks_agent routing; "
|
|
478
|
+
"blocks_agent is reserved for user gates, while agent executor "
|
|
479
|
+
"constraints use excluded_agents",
|
|
480
|
+
)
|
|
481
|
+
excluded_agents = normalize_todo_excluded_agents(
|
|
482
|
+
metadata.get("excluded_agents")
|
|
483
|
+
)
|
|
484
|
+
claimed_by = normalize_todo_claimed_by(metadata.get("claimed_by"))
|
|
485
|
+
if claimed_by and claimed_by in excluded_agents:
|
|
486
|
+
add_error(
|
|
487
|
+
"todo_claimed_by_excluded_agent",
|
|
488
|
+
f"{goal_id}: agent todo {todo_id} has claimed_by={claimed_by!r} "
|
|
489
|
+
"also listed in excluded_agents",
|
|
490
|
+
)
|
|
491
|
+
archived_terminal_todo = (
|
|
492
|
+
in_completed_work_archive
|
|
493
|
+
and todo_status_from_marker(marker) in TERMINAL_TODO_STATUSES
|
|
494
|
+
and status in TERMINAL_TODO_STATUSES
|
|
495
|
+
)
|
|
496
|
+
if role != "agent" and excluded_agents and not archived_terminal_todo:
|
|
497
|
+
add_error(
|
|
498
|
+
"todo_executor_exclusion_scope_invalid",
|
|
499
|
+
f"{goal_id}: {role or 'unscoped'} todo {todo_id} uses excluded_agents; "
|
|
500
|
+
"executor exclusions are only valid for agent todos",
|
|
501
|
+
)
|
|
502
|
+
unknown_excluded_agents = [
|
|
503
|
+
agent_id
|
|
504
|
+
for agent_id in excluded_agents
|
|
505
|
+
if registered_agents and agent_id not in registered_agents
|
|
506
|
+
]
|
|
507
|
+
if role == "agent" and unknown_excluded_agents:
|
|
508
|
+
add_error(
|
|
509
|
+
"todo_excludes_unregistered_agent",
|
|
510
|
+
f"{goal_id}: agent todo {todo_id} excludes unregistered agents: "
|
|
511
|
+
+ ", ".join(unknown_excluded_agents),
|
|
512
|
+
)
|
|
513
|
+
if role == "user" and status not in TERMINAL_TODO_STATUSES:
|
|
514
|
+
checked += 1
|
|
515
|
+
global_gate = metadata.get("global_gate") is True
|
|
516
|
+
bound_agent = normalize_todo_bound_agent(metadata.get("bound_agent"))
|
|
517
|
+
goal_bound = normalize_todo_goal_bound(metadata.get("goal_bound")) is True
|
|
518
|
+
effective_bound_agent = (
|
|
519
|
+
bound_agent
|
|
520
|
+
or (
|
|
521
|
+
blocks_agent
|
|
522
|
+
if task_class == TODO_TASK_CLASS_USER_GATE
|
|
523
|
+
else None
|
|
524
|
+
)
|
|
525
|
+
or claimed_by
|
|
526
|
+
)
|
|
527
|
+
effective_goal_bound = bool(
|
|
528
|
+
goal_bound
|
|
529
|
+
or (
|
|
530
|
+
global_gate
|
|
531
|
+
and task_class == TODO_TASK_CLASS_USER_GATE
|
|
532
|
+
)
|
|
533
|
+
)
|
|
534
|
+
if task_class not in {TODO_TASK_CLASS_USER_ACTION, TODO_TASK_CLASS_USER_GATE}:
|
|
535
|
+
add_error(
|
|
536
|
+
"user_todo_task_class_missing",
|
|
537
|
+
f"{goal_id}: open user todo {todo_id} requires task_class=user_gate "
|
|
538
|
+
"or task_class=user_action "
|
|
539
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
540
|
+
)
|
|
541
|
+
elif task_class == TODO_TASK_CLASS_USER_ACTION and (blocks_agent or global_gate):
|
|
542
|
+
add_error(
|
|
543
|
+
"user_action_blocking_scope_invalid",
|
|
544
|
+
f"{goal_id}: open user_action todo {todo_id} is non-blocking and "
|
|
545
|
+
"cannot set blocks_agent or global_gate=true "
|
|
546
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
547
|
+
)
|
|
548
|
+
elif task_class == TODO_TASK_CLASS_USER_GATE and blocks_agent and global_gate:
|
|
549
|
+
add_error(
|
|
550
|
+
"user_gate_scope_conflict",
|
|
551
|
+
f"{goal_id}: open user_gate todo {todo_id} in multi-agent goal "
|
|
552
|
+
"cannot set both blocks_agent and global_gate=true "
|
|
553
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
554
|
+
)
|
|
555
|
+
elif bound_agent and goal_bound:
|
|
556
|
+
add_error(
|
|
557
|
+
"user_todo_response_scope_conflict",
|
|
558
|
+
f"{goal_id}: open user todo {todo_id} cannot set both "
|
|
559
|
+
"bound_agent and goal_bound=true "
|
|
560
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
561
|
+
)
|
|
562
|
+
elif (
|
|
563
|
+
task_class == TODO_TASK_CLASS_USER_GATE
|
|
564
|
+
and global_gate
|
|
565
|
+
and bound_agent
|
|
566
|
+
):
|
|
567
|
+
add_error(
|
|
568
|
+
"goal_user_gate_agent_binding_invalid",
|
|
569
|
+
f"{goal_id}: goal-wide user_gate todo {todo_id} cannot set "
|
|
570
|
+
"bound_agent; its response binding is goal_bound=true "
|
|
571
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
572
|
+
)
|
|
573
|
+
elif (
|
|
574
|
+
task_class == TODO_TASK_CLASS_USER_GATE
|
|
575
|
+
and blocks_agent
|
|
576
|
+
and goal_bound
|
|
577
|
+
):
|
|
578
|
+
add_error(
|
|
579
|
+
"agent_user_gate_goal_binding_invalid",
|
|
580
|
+
f"{goal_id}: agent-scoped user_gate todo {todo_id} cannot set "
|
|
581
|
+
"goal_bound=true "
|
|
582
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
583
|
+
)
|
|
584
|
+
elif (
|
|
585
|
+
task_class == TODO_TASK_CLASS_USER_GATE
|
|
586
|
+
and blocks_agent
|
|
587
|
+
and bound_agent
|
|
588
|
+
and bound_agent != blocks_agent
|
|
589
|
+
):
|
|
590
|
+
add_error(
|
|
591
|
+
"agent_user_gate_response_binding_mismatch",
|
|
592
|
+
f"{goal_id}: agent-scoped user_gate todo {todo_id} must bind "
|
|
593
|
+
f"to blocks_agent={blocks_agent!r}, not bound_agent="
|
|
594
|
+
f"{bound_agent!r} (state_file={state_file}, line={index + 1}, "
|
|
595
|
+
f"text={text})",
|
|
596
|
+
)
|
|
597
|
+
elif bound_agent and registered_agents and bound_agent not in registered_agents:
|
|
598
|
+
add_error(
|
|
599
|
+
"user_todo_bound_agent_unregistered",
|
|
600
|
+
f"{goal_id}: open user todo {todo_id} has bound_agent="
|
|
601
|
+
f"{bound_agent!r}, which is not registered for this goal "
|
|
602
|
+
f"(registered_agents={', '.join(registered_agents)}, "
|
|
603
|
+
f"state_file={state_file}, line={index + 1}, text={text})",
|
|
604
|
+
)
|
|
605
|
+
elif (
|
|
606
|
+
len(registered_agents) > 1
|
|
607
|
+
and not effective_bound_agent
|
|
608
|
+
and not effective_goal_bound
|
|
609
|
+
):
|
|
610
|
+
add_error(
|
|
611
|
+
"multi_agent_user_todo_missing_response_scope",
|
|
612
|
+
f"{goal_id}: open user todo {todo_id} in multi-agent goal "
|
|
613
|
+
"requires bound_agent=<registered-agent> or goal_bound=true "
|
|
614
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
615
|
+
)
|
|
616
|
+
elif (
|
|
617
|
+
task_class == TODO_TASK_CLASS_USER_GATE
|
|
618
|
+
and blocks_agent
|
|
619
|
+
and registered_agents
|
|
620
|
+
and blocks_agent not in registered_agents
|
|
621
|
+
):
|
|
622
|
+
add_error(
|
|
623
|
+
"user_gate_blocks_unregistered_agent",
|
|
624
|
+
f"{goal_id}: open user_gate todo {todo_id} has blocks_agent="
|
|
625
|
+
f"{blocks_agent!r}, which is not registered for this goal "
|
|
626
|
+
f"(registered_agents={', '.join(registered_agents)}, "
|
|
627
|
+
f"state_file={state_file}, line={index + 1}, text={text})",
|
|
628
|
+
)
|
|
629
|
+
elif (
|
|
630
|
+
task_class == TODO_TASK_CLASS_USER_GATE
|
|
631
|
+
and len(registered_agents) > 1
|
|
632
|
+
and not blocks_agent
|
|
633
|
+
and not global_gate
|
|
634
|
+
):
|
|
635
|
+
add_error(
|
|
636
|
+
"multi_agent_user_gate_missing_scope",
|
|
637
|
+
f"{goal_id}: open user_gate todo {todo_id} in multi-agent goal "
|
|
638
|
+
"requires blocks_agent=<registered-agent> or global_gate=true "
|
|
639
|
+
f"(state_file={state_file}, line={index + 1}, text={text})",
|
|
640
|
+
)
|
|
641
|
+
index = next_index
|
|
642
|
+
return diagnostics, checked
|
|
643
|
+
|
|
644
|
+
|
|
645
|
+
def _active_state_projection_gap_warnings(
|
|
646
|
+
registry: dict[str, Any],
|
|
647
|
+
*,
|
|
648
|
+
goal_id_filter: str | None = None,
|
|
649
|
+
) -> list[str]:
|
|
650
|
+
warnings: list[str] = []
|
|
651
|
+
for goal in registry_goals(registry):
|
|
652
|
+
goal_id = str(goal.get("id") or "")
|
|
653
|
+
if goal_id_filter and goal_id != goal_id_filter:
|
|
654
|
+
continue
|
|
655
|
+
repo_text = str(goal.get("repo") or "").strip()
|
|
656
|
+
if not repo_text:
|
|
657
|
+
continue
|
|
658
|
+
state_file = resolve_state_file(Path(repo_text).expanduser(), goal.get("state_file"))
|
|
659
|
+
if not state_file or not state_file.exists():
|
|
660
|
+
continue
|
|
661
|
+
try:
|
|
662
|
+
state_text = state_file.read_text(encoding="utf-8")
|
|
663
|
+
except OSError:
|
|
664
|
+
continue
|
|
665
|
+
projection_gap = state_projection_gap_warning(state_text)
|
|
666
|
+
if not projection_gap:
|
|
667
|
+
continue
|
|
668
|
+
target_roles = ",".join(str(role) for role in projection_gap.get("target_roles") or [])
|
|
669
|
+
warnings.append(
|
|
670
|
+
f"{goal_id}: active state has a state_projection_gap for {target_roles or 'todo'}; "
|
|
671
|
+
"expand executable Next Action work into an open Agent Todo or user wait into an open User Todo"
|
|
672
|
+
)
|
|
673
|
+
return warnings
|
|
674
|
+
|
|
675
|
+
|
|
676
|
+
def _tracked_scan_files(scan_root: Path) -> list[Path]:
|
|
677
|
+
scan_root = scan_root.resolve()
|
|
678
|
+
target = scan_root if scan_root.is_dir() else scan_root.parent
|
|
679
|
+
try:
|
|
680
|
+
root = subprocess.run(
|
|
681
|
+
["git", "-C", str(target), "rev-parse", "--show-toplevel"],
|
|
682
|
+
text=True,
|
|
683
|
+
encoding="utf-8",
|
|
684
|
+
errors="replace",
|
|
685
|
+
capture_output=True,
|
|
686
|
+
check=True,
|
|
687
|
+
).stdout.strip()
|
|
688
|
+
except (subprocess.CalledProcessError, FileNotFoundError):
|
|
689
|
+
return []
|
|
690
|
+
|
|
691
|
+
repo_root = Path(root).resolve()
|
|
692
|
+
try:
|
|
693
|
+
rel_root = str(scan_root.resolve().relative_to(repo_root.resolve()))
|
|
694
|
+
except ValueError:
|
|
695
|
+
return []
|
|
696
|
+
if not rel_root:
|
|
697
|
+
rel_root = "."
|
|
698
|
+
|
|
699
|
+
tracked = subprocess.run(
|
|
700
|
+
["git", "-C", str(repo_root), "ls-files", "-z", "--", rel_root],
|
|
701
|
+
text=True,
|
|
702
|
+
encoding="utf-8",
|
|
703
|
+
errors="replace",
|
|
704
|
+
capture_output=True,
|
|
705
|
+
check=False,
|
|
706
|
+
)
|
|
707
|
+
if tracked.returncode != 0:
|
|
708
|
+
return []
|
|
709
|
+
|
|
710
|
+
files: list[Path] = []
|
|
711
|
+
for rel_path in tracked.stdout.split("\0"):
|
|
712
|
+
if not rel_path:
|
|
713
|
+
continue
|
|
714
|
+
path = (repo_root / rel_path).resolve()
|
|
715
|
+
if path.name.endswith(".local.json"):
|
|
716
|
+
continue
|
|
717
|
+
if path.is_file() and path.suffix in DEFAULT_SCAN_SUFFIXES:
|
|
718
|
+
files.append(path)
|
|
719
|
+
return files
|
|
720
|
+
|
|
721
|
+
|
|
722
|
+
def iter_scan_files(scan_root: Path) -> list[Path]:
|
|
723
|
+
scan_root = scan_root.resolve()
|
|
724
|
+
if scan_root.is_file():
|
|
725
|
+
return [scan_root]
|
|
726
|
+
files: list[Path] = []
|
|
727
|
+
tracked_files = _tracked_scan_files(scan_root)
|
|
728
|
+
root_parts = set(scan_root.parts)
|
|
729
|
+
if any(part in DEFAULT_SKIP_DIRS or part.endswith(".egg-info") for part in root_parts):
|
|
730
|
+
return sorted(tracked_files)
|
|
731
|
+
|
|
732
|
+
for dir_path, dir_names, file_names in os.walk(scan_root):
|
|
733
|
+
dir_names[:] = [
|
|
734
|
+
name
|
|
735
|
+
for name in dir_names
|
|
736
|
+
if name not in DEFAULT_SKIP_DIRS and not name.endswith(".egg-info")
|
|
737
|
+
]
|
|
738
|
+
current_dir = Path(dir_path)
|
|
739
|
+
for file_name in file_names:
|
|
740
|
+
path = (current_dir / file_name).resolve()
|
|
741
|
+
if path.name.endswith(".local.json"):
|
|
742
|
+
continue
|
|
743
|
+
if not path.is_file():
|
|
744
|
+
continue
|
|
745
|
+
if path.suffix in DEFAULT_SCAN_SUFFIXES:
|
|
746
|
+
files.append(path)
|
|
747
|
+
return sorted(set(files + tracked_files))
|
|
748
|
+
|
|
749
|
+
|
|
750
|
+
def scan_public_boundary(
|
|
751
|
+
scan_roots: list[Path], *, registry: dict[str, Any] | None = None
|
|
752
|
+
) -> dict[str, Any]:
|
|
753
|
+
hits: list[str] = []
|
|
754
|
+
allowed_hits: list[str] = []
|
|
755
|
+
private_state_git_warnings: list[str] = []
|
|
756
|
+
skipped_private_state_files: list[str] = []
|
|
757
|
+
credential_reference_hits: list[str] = []
|
|
758
|
+
unreadable_files: list[str] = []
|
|
759
|
+
files: list[Path] = []
|
|
760
|
+
file_roots: dict[Path, Path] = {}
|
|
761
|
+
for scan_root in scan_roots:
|
|
762
|
+
resolved_scan_root = scan_root.resolve()
|
|
763
|
+
display_root = resolved_scan_root.parent if resolved_scan_root.is_file() else resolved_scan_root
|
|
764
|
+
for file_path in iter_scan_files(resolved_scan_root):
|
|
765
|
+
files.append(file_path)
|
|
766
|
+
file_roots[file_path] = display_root
|
|
767
|
+
files = sorted(set(files))
|
|
768
|
+
policy = _public_boundary_policy(registry or {})
|
|
769
|
+
|
|
770
|
+
for path in files:
|
|
771
|
+
root = file_roots.get(path, path)
|
|
772
|
+
git: dict[str, Any] | None = None
|
|
773
|
+
if _is_local_private_state_path(path):
|
|
774
|
+
git = _git_probe(path)
|
|
775
|
+
if not git.get("tracked"):
|
|
776
|
+
skipped_private_state_files.append(rel_or_abs(path, root))
|
|
777
|
+
if git.get("inside_worktree") and not git.get("ignored"):
|
|
778
|
+
private_state_git_warnings.append(
|
|
779
|
+
f"{rel_or_abs(path, root)}: private state should be gitignored"
|
|
780
|
+
)
|
|
781
|
+
continue
|
|
782
|
+
try:
|
|
783
|
+
text = path.read_text(encoding="utf-8")
|
|
784
|
+
except UnicodeDecodeError:
|
|
785
|
+
continue
|
|
786
|
+
except OSError as exc:
|
|
787
|
+
unreadable_files.append(f"{rel_or_abs(path, root)}: {exc.strerror or exc}")
|
|
788
|
+
continue
|
|
789
|
+
for line_no, line in enumerate(text.splitlines(), start=1):
|
|
790
|
+
for name, pattern in LEAK_PATTERNS.items():
|
|
791
|
+
if pattern.search(line):
|
|
792
|
+
hit = f"{rel_or_abs(path, root)}:{line_no}: {name}"
|
|
793
|
+
if name == "credential" and _credential_hits_are_all_references(line):
|
|
794
|
+
credential_reference_hits.append(hit)
|
|
795
|
+
continue
|
|
796
|
+
if name == "private_doc_url":
|
|
797
|
+
git = git or _git_probe(path)
|
|
798
|
+
if git is not None and _hit_allowed_by_policy(name, git, policy):
|
|
799
|
+
allowed_hits.append(hit)
|
|
800
|
+
else:
|
|
801
|
+
hits.append(hit)
|
|
802
|
+
return {
|
|
803
|
+
"ok": not hits,
|
|
804
|
+
"scan_roots": [str(path) for path in scan_roots],
|
|
805
|
+
"files": len(files),
|
|
806
|
+
"scanned_files": len(files) - len(skipped_private_state_files),
|
|
807
|
+
"skipped_private_state_files": skipped_private_state_files,
|
|
808
|
+
"credential_reference_hits": credential_reference_hits,
|
|
809
|
+
"unreadable_files": unreadable_files,
|
|
810
|
+
"allowed_hits": allowed_hits,
|
|
811
|
+
"private_state_git_warnings": private_state_git_warnings,
|
|
812
|
+
"policy": policy,
|
|
813
|
+
"hits": hits,
|
|
814
|
+
}
|
|
815
|
+
|
|
816
|
+
|
|
817
|
+
def check_contract(
|
|
818
|
+
*,
|
|
819
|
+
registry_path: Path,
|
|
820
|
+
runtime_root_override: str | None,
|
|
821
|
+
scan_roots: list[Path],
|
|
822
|
+
limit: int,
|
|
823
|
+
allow_missing_registry: bool = False,
|
|
824
|
+
goal_id_filter: str | None = None,
|
|
825
|
+
) -> dict[str, Any]:
|
|
826
|
+
error_diagnostics: list[dict[str, Any]] = []
|
|
827
|
+
warnings: list[str] = []
|
|
828
|
+
checks: list[str] = []
|
|
829
|
+
|
|
830
|
+
def add_global_error(code: str, message: str) -> None:
|
|
831
|
+
error_diagnostics.append(
|
|
832
|
+
contract_error_diagnostic(code=code, message=message)
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
registry_payload = inspect_registry(registry_path)
|
|
836
|
+
if registry_payload.get("ok"):
|
|
837
|
+
checks.append(f"registry goals checked: {registry_payload.get('goal_count')}")
|
|
838
|
+
else:
|
|
839
|
+
if registry_payload.get("error"):
|
|
840
|
+
error = str(registry_payload.get("error"))
|
|
841
|
+
if allow_missing_registry and error == "registry file does not exist":
|
|
842
|
+
warnings.append(f"{error}: {registry_path}")
|
|
843
|
+
else:
|
|
844
|
+
add_global_error("registry_unavailable", error)
|
|
845
|
+
problem_diagnostics = registry_payload.get("problem_diagnostics")
|
|
846
|
+
if isinstance(problem_diagnostics, list):
|
|
847
|
+
error_diagnostics.extend(
|
|
848
|
+
item for item in problem_diagnostics if isinstance(item, dict)
|
|
849
|
+
)
|
|
850
|
+
else:
|
|
851
|
+
for problem in registry_payload.get("problems") or []:
|
|
852
|
+
add_global_error("registry_problem", str(problem))
|
|
853
|
+
|
|
854
|
+
boundary_payload = inspect_registry_boundary(registry_path)
|
|
855
|
+
if boundary_payload.get("ok"):
|
|
856
|
+
git = boundary_payload.get("git") if isinstance(boundary_payload.get("git"), dict) else {}
|
|
857
|
+
checks.append(
|
|
858
|
+
"registry boundary: "
|
|
859
|
+
f"{boundary_payload.get('classification')} "
|
|
860
|
+
f"push_allowed={boundary_payload.get('github_push_allowed')} "
|
|
861
|
+
f"tracked={git.get('tracked')} ignored={git.get('ignored')}"
|
|
862
|
+
)
|
|
863
|
+
if boundary_payload.get("should_be_gitignored") and git.get("inside_worktree"):
|
|
864
|
+
if not git.get("ignored") and not git.get("tracked"):
|
|
865
|
+
warnings.append(f"registry should be gitignored: {registry_path}")
|
|
866
|
+
else:
|
|
867
|
+
if boundary_payload.get("error"):
|
|
868
|
+
warnings.append(f"registry boundary unavailable: {boundary_payload.get('error')}")
|
|
869
|
+
for risk in boundary_payload.get("risks") or []:
|
|
870
|
+
add_global_error("registry_boundary_risk", f"registry boundary risk: {risk}")
|
|
871
|
+
|
|
872
|
+
registry = load_registry(registry_path)
|
|
873
|
+
todo_contract_diagnostics, checked_user_gates = (
|
|
874
|
+
_active_state_todo_contract_diagnostics(
|
|
875
|
+
registry,
|
|
876
|
+
goal_id_filter=goal_id_filter,
|
|
877
|
+
)
|
|
878
|
+
)
|
|
879
|
+
if checked_user_gates:
|
|
880
|
+
checks.append(f"user-gate scopes checked: {checked_user_gates} open multi-agent gates")
|
|
881
|
+
error_diagnostics.extend(todo_contract_diagnostics)
|
|
882
|
+
warnings.extend(
|
|
883
|
+
_active_state_projection_gap_warnings(
|
|
884
|
+
registry,
|
|
885
|
+
goal_id_filter=goal_id_filter,
|
|
886
|
+
)
|
|
887
|
+
)
|
|
888
|
+
|
|
889
|
+
runtime_root = resolve_runtime_root(
|
|
890
|
+
registry,
|
|
891
|
+
runtime_root_override,
|
|
892
|
+
registry_path=registry_path,
|
|
893
|
+
)
|
|
894
|
+
if runtime_root == DEFAULT_RUNTIME_ROOT or runtime_root.exists():
|
|
895
|
+
checks.append(f"runtime root resolved: {runtime_root}")
|
|
896
|
+
else:
|
|
897
|
+
warnings.append(f"runtime root does not exist yet: {runtime_root}")
|
|
898
|
+
|
|
899
|
+
history = collect_history(
|
|
900
|
+
registry_path=registry_path,
|
|
901
|
+
runtime_root=runtime_root,
|
|
902
|
+
goal_id=goal_id_filter,
|
|
903
|
+
limit=limit,
|
|
904
|
+
)
|
|
905
|
+
checks.append(f"run-history goals={history.get('goal_count')} runs={history.get('run_count')}")
|
|
906
|
+
for item in history.get("goals") or []:
|
|
907
|
+
raw = int(item.get("raw_index_records") or 0)
|
|
908
|
+
unique = int(item.get("unique_runs") or 0)
|
|
909
|
+
if item.get("legacy_runtime_goal") and raw > unique:
|
|
910
|
+
checks.append(f"{item.get('id')}: legacy runtime goal has duplicate rows raw={raw} unique={unique}")
|
|
911
|
+
continue
|
|
912
|
+
if raw > unique:
|
|
913
|
+
duplicate_summary = _index_duplicate_summary(Path(str(item.get("index_path") or "")))
|
|
914
|
+
if duplicate_summary.get("unexpected_duplicate_rows"):
|
|
915
|
+
warnings.append(_index_duplicate_warning(item.get("id"), raw, unique, duplicate_summary))
|
|
916
|
+
else:
|
|
917
|
+
emitted_check = False
|
|
918
|
+
if duplicate_summary.get("reward_overlay_rows"):
|
|
919
|
+
emitted_check = True
|
|
920
|
+
checks.append(
|
|
921
|
+
f"{item.get('id')}: reward overlay rows raw={raw} unique={unique} "
|
|
922
|
+
f"overlays={duplicate_summary.get('reward_overlay_rows')}"
|
|
923
|
+
)
|
|
924
|
+
if duplicate_summary.get("structured_artifact_bundle_rows"):
|
|
925
|
+
emitted_check = True
|
|
926
|
+
checks.append(
|
|
927
|
+
f"{item.get('id')}: structured artifact bundle rows raw={raw} unique={unique} "
|
|
928
|
+
f"bundles={duplicate_summary.get('structured_artifact_bundle_rows')}"
|
|
929
|
+
)
|
|
930
|
+
if not emitted_check:
|
|
931
|
+
warnings.append(_index_duplicate_warning(item.get("id"), raw, unique, duplicate_summary))
|
|
932
|
+
|
|
933
|
+
boundary = scan_public_boundary(scan_roots, registry=registry)
|
|
934
|
+
if boundary.get("ok"):
|
|
935
|
+
checks.append(f"public boundary scan clean: {boundary.get('scanned_files')} files")
|
|
936
|
+
else:
|
|
937
|
+
for hit in boundary.get("hits") or []:
|
|
938
|
+
add_global_error("public_boundary_violation", str(hit))
|
|
939
|
+
if boundary.get("skipped_private_state_files"):
|
|
940
|
+
checks.append(
|
|
941
|
+
"private state scan skipped: "
|
|
942
|
+
f"{len(boundary.get('skipped_private_state_files') or [])} local-private files"
|
|
943
|
+
)
|
|
944
|
+
if boundary.get("credential_reference_hits"):
|
|
945
|
+
checks.append(
|
|
946
|
+
"credential references downgraded: "
|
|
947
|
+
f"{len(boundary.get('credential_reference_hits') or [])} non-literal hits"
|
|
948
|
+
)
|
|
949
|
+
if boundary.get("allowed_hits"):
|
|
950
|
+
checks.append(
|
|
951
|
+
"public boundary policy allowed: "
|
|
952
|
+
f"{len(boundary.get('allowed_hits') or [])} private_doc_url hits"
|
|
953
|
+
)
|
|
954
|
+
warnings.extend(str(item) for item in boundary.get("private_state_git_warnings") or [])
|
|
955
|
+
warnings.extend(
|
|
956
|
+
f"unreadable file skipped: {item}" for item in boundary.get("unreadable_files") or []
|
|
957
|
+
)
|
|
958
|
+
error_views = contract_error_views(error_diagnostics)
|
|
959
|
+
errors = error_views["errors"]
|
|
960
|
+
|
|
961
|
+
payload = {
|
|
962
|
+
"ok": not errors,
|
|
963
|
+
"registry": str(registry_path),
|
|
964
|
+
"runtime_root": str(runtime_root),
|
|
965
|
+
"scan_roots": [str(path) for path in scan_roots],
|
|
966
|
+
"summary": {
|
|
967
|
+
"errors": len(errors),
|
|
968
|
+
"warnings": len(warnings),
|
|
969
|
+
"checks": len(checks),
|
|
970
|
+
},
|
|
971
|
+
**error_views,
|
|
972
|
+
"warnings": warnings,
|
|
973
|
+
"checks": checks,
|
|
974
|
+
}
|
|
975
|
+
return project_contract_health_for_goal(payload, goal_id=goal_id_filter)
|
|
976
|
+
|
|
977
|
+
|
|
978
|
+
def render_contract_markdown(payload: dict[str, Any]) -> str:
|
|
979
|
+
lines = [
|
|
980
|
+
"# LoopX Contract Check",
|
|
981
|
+
"",
|
|
982
|
+
f"- ok: `{payload.get('ok')}`",
|
|
983
|
+
f"- registry: `{payload.get('registry')}`",
|
|
984
|
+
f"- runtime_root: `{payload.get('runtime_root')}`",
|
|
985
|
+
f"- scan_roots: `{payload.get('scan_roots')}`",
|
|
986
|
+
]
|
|
987
|
+
summary = payload.get("summary") or {}
|
|
988
|
+
lines.append(
|
|
989
|
+
f"- summary: errors={summary.get('errors')}, warnings={summary.get('warnings')}, checks={summary.get('checks')}"
|
|
990
|
+
)
|
|
991
|
+
for title, key in (("Errors", "errors"), ("Warnings", "warnings"), ("Checks", "checks")):
|
|
992
|
+
items = payload.get(key) or []
|
|
993
|
+
if items:
|
|
994
|
+
lines.extend(["", f"## {title}"])
|
|
995
|
+
lines.extend(f"- {item}" for item in items)
|
|
996
|
+
return "\n".join(lines)
|