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
|
@@ -0,0 +1,1085 @@
|
|
|
1
|
+
"""Small read-model helpers for auto-research worker state.
|
|
2
|
+
|
|
3
|
+
This module turns LoopX quota/todo state and rollout evidence events into the
|
|
4
|
+
minimal frontier, evidence graph, and decision-candidate shapes that worker
|
|
5
|
+
turns need. It intentionally avoids demo boards, starter packs, and other
|
|
6
|
+
legacy presentation code.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import json
|
|
12
|
+
import re
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
from .evidence_packet import (
|
|
17
|
+
METRIC_DIRECTIONS,
|
|
18
|
+
RESEARCH_FAILURE_KINDS,
|
|
19
|
+
RESEARCH_EVIDENCE_EVENT_SCHEMA_VERSION,
|
|
20
|
+
RESEARCH_HYPOTHESIS_SCHEMA_VERSION,
|
|
21
|
+
_compact_public_text,
|
|
22
|
+
_compact_public_text_list,
|
|
23
|
+
_compact_public_token,
|
|
24
|
+
_derive_hypothesis_status,
|
|
25
|
+
_finite_float,
|
|
26
|
+
_is_negative_evidence_event,
|
|
27
|
+
_is_retry_evidence_event,
|
|
28
|
+
_json_list,
|
|
29
|
+
_json_obj,
|
|
30
|
+
_metric_improved,
|
|
31
|
+
_metric_rank_key,
|
|
32
|
+
validate_research_contract,
|
|
33
|
+
validate_research_evidence_event,
|
|
34
|
+
validate_research_hypothesis,
|
|
35
|
+
)
|
|
36
|
+
from .preset import AUTO_RESEARCH_REQUIRED_HOLDOUT_IMPROVEMENTS
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
AUTO_RESEARCH_FIXTURE_SCHEMA_VERSION = "decentralized_auto_research_fixture_v0"
|
|
40
|
+
AUTO_RESEARCH_PROJECTION_SCHEMA_VERSION = "decentralized_auto_research_projection_v0"
|
|
41
|
+
RESEARCH_EVIDENCE_GRAPH_SCHEMA_VERSION = "research_evidence_graph_v0"
|
|
42
|
+
RESEARCH_FRONTIER_SCHEMA_VERSION = "decentralized_research_frontier_v0"
|
|
43
|
+
AUTO_RESEARCH_COMPLETION_STATUS_SCHEMA_VERSION = "auto_research_completion_status_v0"
|
|
44
|
+
ROLLOUT_EVIDENCE_GRAPH_SOURCE_KIND = "loopx_rollout_event_log"
|
|
45
|
+
AUTO_RESEARCH_ACTION_ALIASES = {
|
|
46
|
+
"run_read_only_adapter_tick": "run_dev_eval",
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
def load_auto_research_fixture(path: str | Path) -> dict[str, Any]:
|
|
51
|
+
payload = json.loads(Path(path).expanduser().read_text(encoding="utf-8"))
|
|
52
|
+
return validate_auto_research_fixture(payload)
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
def validate_auto_research_fixture(payload: dict[str, Any]) -> dict[str, Any]:
|
|
56
|
+
payload = _json_obj(payload, field="fixture")
|
|
57
|
+
schema = _compact_public_token(payload.get("schema_version"), field="schema_version")
|
|
58
|
+
if schema != AUTO_RESEARCH_FIXTURE_SCHEMA_VERSION:
|
|
59
|
+
raise ValueError(f"schema_version must be {AUTO_RESEARCH_FIXTURE_SCHEMA_VERSION}")
|
|
60
|
+
|
|
61
|
+
contract = validate_research_contract(_json_obj(payload.get("research_contract"), field="research_contract"))
|
|
62
|
+
hypotheses = [
|
|
63
|
+
validate_research_hypothesis(_json_obj(item, field="hypotheses[]"))
|
|
64
|
+
for item in _json_list(payload.get("hypotheses"), field="hypotheses")
|
|
65
|
+
]
|
|
66
|
+
evidence_events = [
|
|
67
|
+
validate_research_evidence_event(_json_obj(item, field="evidence_events[]"))
|
|
68
|
+
for item in _json_list(payload.get("evidence_events"), field="evidence_events")
|
|
69
|
+
]
|
|
70
|
+
|
|
71
|
+
hypothesis_ids = {item["hypothesis_id"] for item in hypotheses}
|
|
72
|
+
todo_ids = {item["todo_id"] for item in hypotheses if item.get("todo_id")}
|
|
73
|
+
for item in evidence_events:
|
|
74
|
+
if item["hypothesis_id"] not in hypothesis_ids:
|
|
75
|
+
raise ValueError(f"evidence references unknown hypothesis_id {item['hypothesis_id']}")
|
|
76
|
+
if item.get("todo_id") and item["todo_id"] not in todo_ids:
|
|
77
|
+
raise ValueError(f"evidence references unknown todo_id {item['todo_id']}")
|
|
78
|
+
|
|
79
|
+
agents = [
|
|
80
|
+
_compact_public_token(value, field="agents[]")
|
|
81
|
+
for value in _json_list(payload.get("agents"), field="agents")
|
|
82
|
+
]
|
|
83
|
+
|
|
84
|
+
return {
|
|
85
|
+
"schema_version": schema,
|
|
86
|
+
"generated_at": _compact_public_text(payload.get("generated_at"), field="generated_at"),
|
|
87
|
+
"research_contract": contract,
|
|
88
|
+
"agents": agents,
|
|
89
|
+
"hypotheses": hypotheses,
|
|
90
|
+
"evidence_events": evidence_events,
|
|
91
|
+
"raw_logs_recorded": False,
|
|
92
|
+
"private_artifacts_recorded": False,
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def _compact_optional_token(value: Any, *, field: str, default: str) -> str:
|
|
97
|
+
if value is None or str(value).strip() == "":
|
|
98
|
+
return default
|
|
99
|
+
return _compact_public_token(value, field=field)
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
def _compact_optional_text(value: Any, *, field: str, default: str, max_len: int = 240) -> str:
|
|
103
|
+
if value is None or str(value).strip() == "":
|
|
104
|
+
return default
|
|
105
|
+
text = " ".join(str(value).strip().split())
|
|
106
|
+
if len(text) > max_len:
|
|
107
|
+
prefix = text[: max_len - 1].rstrip()
|
|
108
|
+
if prefix.endswith(".") and not prefix.endswith(".."):
|
|
109
|
+
text = prefix
|
|
110
|
+
else:
|
|
111
|
+
text = prefix.rstrip(".") + "."
|
|
112
|
+
# Strip trailing dot-runs so public text validation does not flag them
|
|
113
|
+
# as parent-directory markers (text may arrive with "..." from upstream).
|
|
114
|
+
while text.endswith(".."):
|
|
115
|
+
text = text[:-1]
|
|
116
|
+
return _compact_public_text(text, field=field, max_len=max_len)
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
def _live_hypothesis_id(todo_id: str) -> str:
|
|
120
|
+
suffix = re.sub(r"[^A-Za-z0-9_:-]+", "_", todo_id.replace("todo_", "", 1))
|
|
121
|
+
return _compact_public_token(f"hyp_{suffix}", field="live.hypothesis_id")
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def _claimed_by_current_or_unclaimed(item: dict[str, Any], *, agent_id: str) -> bool:
|
|
125
|
+
claimed_by = str(item.get("claimed_by") or "").strip()
|
|
126
|
+
return not claimed_by or claimed_by == agent_id
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _public_todo_items(value: Any) -> list[dict[str, Any]]:
|
|
130
|
+
return [item for item in value or [] if isinstance(item, dict) and item.get("todo_id")]
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def _is_runnable_advancement_todo(item: dict[str, Any]) -> bool:
|
|
134
|
+
task_class = str(item.get("task_class") or "advancement_task").strip()
|
|
135
|
+
if task_class and task_class != "advancement_task":
|
|
136
|
+
return False
|
|
137
|
+
status = str(item.get("status") or "open").strip()
|
|
138
|
+
if status and status not in {"active", "open", "needs_retry"}:
|
|
139
|
+
return False
|
|
140
|
+
resume_when = str(item.get("resume_when") or "").strip()
|
|
141
|
+
if resume_when and item.get("resume_ready") is False:
|
|
142
|
+
return False
|
|
143
|
+
return True
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
def _unique_todo_candidates(items: list[dict[str, Any]]) -> list[dict[str, Any]]:
|
|
147
|
+
selected: list[dict[str, Any]] = []
|
|
148
|
+
seen: set[str] = set()
|
|
149
|
+
for item in items:
|
|
150
|
+
todo_id = str(item.get("todo_id") or "").strip()
|
|
151
|
+
if not todo_id or todo_id in seen:
|
|
152
|
+
continue
|
|
153
|
+
seen.add(todo_id)
|
|
154
|
+
selected.append(item)
|
|
155
|
+
return selected
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
def _quota_payload_todo_candidates(
|
|
159
|
+
quota_payload: dict[str, Any],
|
|
160
|
+
) -> tuple[list[dict[str, Any]], list[dict[str, Any]]]:
|
|
161
|
+
gate = quota_payload.get("capability_gate")
|
|
162
|
+
if not isinstance(gate, dict):
|
|
163
|
+
gate = {}
|
|
164
|
+
runnable = _public_todo_items(gate.get("runnable_candidates"))
|
|
165
|
+
blocked = _public_todo_items(gate.get("blocked_candidates"))
|
|
166
|
+
|
|
167
|
+
agent_summary = quota_payload.get("agent_todo_summary")
|
|
168
|
+
if not isinstance(agent_summary, dict):
|
|
169
|
+
return _unique_todo_candidates(runnable), _unique_todo_candidates(blocked)
|
|
170
|
+
|
|
171
|
+
for key in (
|
|
172
|
+
"active_next_action_executable_items",
|
|
173
|
+
"first_executable_items",
|
|
174
|
+
"claimed_advancement_open_items",
|
|
175
|
+
"unclaimed_advancement_open_items",
|
|
176
|
+
):
|
|
177
|
+
runnable.extend(
|
|
178
|
+
item
|
|
179
|
+
for item in _public_todo_items(agent_summary.get(key))
|
|
180
|
+
if _is_runnable_advancement_todo(item)
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
claim_scope = agent_summary.get("claim_scope")
|
|
184
|
+
if not isinstance(claim_scope, dict):
|
|
185
|
+
claim_scope = {}
|
|
186
|
+
for key in ("claimed_by_others_items", "blocked_claimed_items", "blocked_items"):
|
|
187
|
+
blocked.extend(_public_todo_items(agent_summary.get(key)))
|
|
188
|
+
blocked.extend(_public_todo_items(claim_scope.get(key)))
|
|
189
|
+
|
|
190
|
+
return _unique_todo_candidates(runnable), _unique_todo_candidates(blocked)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def normalize_auto_research_action(action: object) -> str:
|
|
194
|
+
raw = str(action or "").strip()
|
|
195
|
+
return AUTO_RESEARCH_ACTION_ALIASES.get(raw, raw)
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
def _todo_frontier_item(
|
|
199
|
+
item: dict[str, Any],
|
|
200
|
+
*,
|
|
201
|
+
default_agent_id: str,
|
|
202
|
+
blocked_by: str | None = None,
|
|
203
|
+
) -> dict[str, Any]:
|
|
204
|
+
todo_id = _compact_public_token(item.get("todo_id"), field="live.todo_id")
|
|
205
|
+
claimed_by = _compact_optional_token(
|
|
206
|
+
item.get("claimed_by"),
|
|
207
|
+
field="live.claimed_by",
|
|
208
|
+
default=default_agent_id,
|
|
209
|
+
)
|
|
210
|
+
status = _compact_optional_token(item.get("status"), field="live.status", default="open")
|
|
211
|
+
summary = {
|
|
212
|
+
"hypothesis_id": _live_hypothesis_id(todo_id),
|
|
213
|
+
"todo_id": todo_id,
|
|
214
|
+
"claimed_by": claimed_by,
|
|
215
|
+
"status": "active" if status == "open" else status,
|
|
216
|
+
"mechanism_family": _compact_optional_text(
|
|
217
|
+
item.get("action_kind") or item.get("task_class") or "advancement_task",
|
|
218
|
+
field="live.mechanism_family",
|
|
219
|
+
default="advancement_task",
|
|
220
|
+
max_len=96,
|
|
221
|
+
),
|
|
222
|
+
"source_kind": "todo_item_v0",
|
|
223
|
+
"title": _compact_optional_text(
|
|
224
|
+
item.get("title") or item.get("text"),
|
|
225
|
+
field="live.title",
|
|
226
|
+
default=todo_id,
|
|
227
|
+
max_len=220,
|
|
228
|
+
),
|
|
229
|
+
}
|
|
230
|
+
unblocks_todo_id = _compact_optional_token(
|
|
231
|
+
item.get("unblocks_todo_id"),
|
|
232
|
+
field="live.unblocks_todo_id",
|
|
233
|
+
default="",
|
|
234
|
+
)
|
|
235
|
+
if unblocks_todo_id:
|
|
236
|
+
summary["unblocks_todo_id"] = unblocks_todo_id
|
|
237
|
+
resume_when = _compact_optional_text(
|
|
238
|
+
item.get("resume_when"),
|
|
239
|
+
field="live.resume_when",
|
|
240
|
+
default="",
|
|
241
|
+
max_len=160,
|
|
242
|
+
)
|
|
243
|
+
if resume_when:
|
|
244
|
+
summary["resume_when"] = resume_when
|
|
245
|
+
if blocked_by:
|
|
246
|
+
summary["blocked_by"] = _compact_public_text(blocked_by, field="live.blocked_by", max_len=160)
|
|
247
|
+
else:
|
|
248
|
+
summary["allowed_action"] = _compact_optional_text(
|
|
249
|
+
normalize_auto_research_action(item.get("action_kind") or "advance_todo"),
|
|
250
|
+
field="live.allowed_action",
|
|
251
|
+
default="advance_todo",
|
|
252
|
+
max_len=96,
|
|
253
|
+
)
|
|
254
|
+
return summary
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
def _rollout_source_refs(event: dict[str, Any]) -> tuple[list[str], str | None]:
|
|
258
|
+
grounding_refs: list[str] = []
|
|
259
|
+
novelty_audit_ref: str | None = None
|
|
260
|
+
for index, ref in enumerate(event.get("source_refs") or []):
|
|
261
|
+
if not isinstance(ref, dict):
|
|
262
|
+
continue
|
|
263
|
+
kind = str(ref.get("kind") or "").strip()
|
|
264
|
+
ref_id = ref.get("id")
|
|
265
|
+
if not ref_id:
|
|
266
|
+
continue
|
|
267
|
+
if kind == "grounding":
|
|
268
|
+
grounding_refs.append(
|
|
269
|
+
_compact_public_text(ref_id, field=f"rollout.source_refs[{index}].id")
|
|
270
|
+
)
|
|
271
|
+
elif kind == "novelty_audit" and novelty_audit_ref is None:
|
|
272
|
+
novelty_audit_ref = _compact_public_text(
|
|
273
|
+
ref_id,
|
|
274
|
+
field=f"rollout.source_refs[{index}].id",
|
|
275
|
+
)
|
|
276
|
+
return grounding_refs, novelty_audit_ref
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
def _rollout_hypothesis_text(event: dict[str, Any], details: dict[str, Any]) -> str:
|
|
280
|
+
if details.get("hypothesis"):
|
|
281
|
+
return _compact_public_text(details["hypothesis"], field="rollout.details.hypothesis")
|
|
282
|
+
summary = str(event.get("summary") or "")
|
|
283
|
+
prefix = "auto-research hypothesis "
|
|
284
|
+
if summary.startswith(prefix) and ": " in summary:
|
|
285
|
+
return _compact_public_text(
|
|
286
|
+
summary.split(": ", 1)[1],
|
|
287
|
+
field="rollout.summary.hypothesis",
|
|
288
|
+
)
|
|
289
|
+
fallback = f"Evidence-backed hypothesis {details.get('hypothesis_id') or event.get('todo_id')}"
|
|
290
|
+
return _compact_public_text(fallback, field="rollout.summary.hypothesis")
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def _research_hypothesis_from_rollout_event(event: dict[str, Any]) -> dict[str, Any] | None:
|
|
294
|
+
if str(event.get("event_kind") or "") != "research_hypothesis":
|
|
295
|
+
return None
|
|
296
|
+
if str(event.get("classification") or "") != RESEARCH_HYPOTHESIS_SCHEMA_VERSION:
|
|
297
|
+
return None
|
|
298
|
+
details = _json_obj(event.get("details") or {}, field="rollout.hypothesis.details")
|
|
299
|
+
grounding_refs, novelty_audit_ref = _rollout_source_refs(event)
|
|
300
|
+
negative_count = int(details.get("negative_evidence_count") or 0)
|
|
301
|
+
retry_count = int(details.get("needs_retry_count") or 0)
|
|
302
|
+
status = details.get("status") or event.get("status") or "active"
|
|
303
|
+
blocked_by: list[str] = []
|
|
304
|
+
if str(status) == "contradicted" or negative_count:
|
|
305
|
+
blocked_by.append("evidence_or_boundary_guardrail_failed")
|
|
306
|
+
elif str(status) == "needs_retry" or retry_count:
|
|
307
|
+
blocked_by.append("needs_retry_evidence")
|
|
308
|
+
return validate_research_hypothesis(
|
|
309
|
+
{
|
|
310
|
+
"schema_version": RESEARCH_HYPOTHESIS_SCHEMA_VERSION,
|
|
311
|
+
"hypothesis_id": details.get("hypothesis_id"),
|
|
312
|
+
"parent_hypothesis_id": details.get("parent_hypothesis_id") or None,
|
|
313
|
+
"todo_id": event.get("todo_id"),
|
|
314
|
+
"claimed_by": event.get("agent_id") or "unknown_agent",
|
|
315
|
+
"mechanism_family": details.get("mechanism_family") or "rollout_imported",
|
|
316
|
+
"hypothesis": _rollout_hypothesis_text(event, details),
|
|
317
|
+
"status": status,
|
|
318
|
+
"grounding_refs": grounding_refs,
|
|
319
|
+
"novelty_audit_ref": novelty_audit_ref,
|
|
320
|
+
"blocked_by": blocked_by,
|
|
321
|
+
}
|
|
322
|
+
)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
def _research_evidence_from_rollout_event(event: dict[str, Any]) -> dict[str, Any] | None:
|
|
326
|
+
if str(event.get("event_kind") or "") != "research_evidence":
|
|
327
|
+
return None
|
|
328
|
+
if str(event.get("classification") or "") != RESEARCH_EVIDENCE_EVENT_SCHEMA_VERSION:
|
|
329
|
+
return None
|
|
330
|
+
details = _json_obj(event.get("details") or {}, field="rollout.evidence.details")
|
|
331
|
+
return validate_research_evidence_event(
|
|
332
|
+
{
|
|
333
|
+
"schema_version": RESEARCH_EVIDENCE_EVENT_SCHEMA_VERSION,
|
|
334
|
+
"hypothesis_id": details.get("hypothesis_id"),
|
|
335
|
+
"todo_id": event.get("todo_id"),
|
|
336
|
+
"agent_id": event.get("agent_id") or "unknown_agent",
|
|
337
|
+
"attempt": details.get("attempt") or 1,
|
|
338
|
+
"split": details.get("split"),
|
|
339
|
+
"metric": {
|
|
340
|
+
"name": details.get("metric_name"),
|
|
341
|
+
"value": details.get("metric_value"),
|
|
342
|
+
"direction": details.get("metric_direction"),
|
|
343
|
+
},
|
|
344
|
+
"baseline_metric": details.get("baseline_metric"),
|
|
345
|
+
"eval_status": details.get("eval_status") or event.get("status"),
|
|
346
|
+
"primary_metric_status": details.get("primary_metric_status") or "inconclusive",
|
|
347
|
+
"failure_kind": details.get("failure_kind") or None,
|
|
348
|
+
"measurement_scope": details.get("measurement_scope") or None,
|
|
349
|
+
"remediation_attempt": bool(details.get("remediation_attempt")),
|
|
350
|
+
"artifact_refs": event.get("artifact_refs") or [],
|
|
351
|
+
"protected_scope_clean": bool(details.get("protected_scope_clean")),
|
|
352
|
+
}
|
|
353
|
+
)
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
def _synthetic_hypothesis_from_evidence(events: list[dict[str, Any]]) -> dict[str, Any]:
|
|
357
|
+
first = events[0]
|
|
358
|
+
status = _derive_hypothesis_status(events)
|
|
359
|
+
blocked_by = []
|
|
360
|
+
if status == "contradicted":
|
|
361
|
+
blocked_by.append("evidence_or_boundary_guardrail_failed")
|
|
362
|
+
elif status == "needs_retry":
|
|
363
|
+
blocked_by.append("needs_retry_evidence")
|
|
364
|
+
return validate_research_hypothesis(
|
|
365
|
+
{
|
|
366
|
+
"schema_version": RESEARCH_HYPOTHESIS_SCHEMA_VERSION,
|
|
367
|
+
"hypothesis_id": first["hypothesis_id"],
|
|
368
|
+
"parent_hypothesis_id": None,
|
|
369
|
+
"todo_id": first["todo_id"],
|
|
370
|
+
"claimed_by": first["agent_id"],
|
|
371
|
+
"mechanism_family": "rollout_evidence_only",
|
|
372
|
+
"hypothesis": f"Evidence-backed hypothesis {first['hypothesis_id']}",
|
|
373
|
+
"status": status,
|
|
374
|
+
"grounding_refs": [],
|
|
375
|
+
"novelty_audit_ref": None,
|
|
376
|
+
"blocked_by": blocked_by,
|
|
377
|
+
}
|
|
378
|
+
)
|
|
379
|
+
|
|
380
|
+
|
|
381
|
+
def _best_metric(events: list[dict[str, Any]], *, split: str, direction: str) -> float | None:
|
|
382
|
+
values = [
|
|
383
|
+
event["metric"]["value"]
|
|
384
|
+
for event in events
|
|
385
|
+
if event["split"] == split and event["eval_status"] == "scored"
|
|
386
|
+
]
|
|
387
|
+
if not values:
|
|
388
|
+
return None
|
|
389
|
+
return max(values, key=lambda value: _metric_rank_key(value, direction=direction))
|
|
390
|
+
|
|
391
|
+
|
|
392
|
+
def _default_failure_kind(
|
|
393
|
+
*,
|
|
394
|
+
status: str,
|
|
395
|
+
events: list[dict[str, Any]],
|
|
396
|
+
) -> str | None:
|
|
397
|
+
explicit = [event for event in events if event.get("failure_kind")]
|
|
398
|
+
if explicit:
|
|
399
|
+
return str(explicit[-1]["failure_kind"])
|
|
400
|
+
if any(not event["protected_scope_clean"] for event in events):
|
|
401
|
+
return "guardrail_or_protected_boundary"
|
|
402
|
+
if status == "needs_retry":
|
|
403
|
+
return None
|
|
404
|
+
return "mechanism_contradicted"
|
|
405
|
+
|
|
406
|
+
|
|
407
|
+
def _failure_measurement_scope(events: list[dict[str, Any]]) -> str | None:
|
|
408
|
+
values = [
|
|
409
|
+
str(event.get("measurement_scope") or "").strip()
|
|
410
|
+
for event in events
|
|
411
|
+
if event.get("measurement_scope")
|
|
412
|
+
]
|
|
413
|
+
return values[-1] if values else None
|
|
414
|
+
|
|
415
|
+
|
|
416
|
+
def _ancestor_hypothesis_ids(
|
|
417
|
+
hypothesis_id: str,
|
|
418
|
+
*,
|
|
419
|
+
hypotheses: dict[str, dict[str, Any]],
|
|
420
|
+
) -> set[str]:
|
|
421
|
+
ancestor_ids: set[str] = set()
|
|
422
|
+
current_id = hypothesis_id
|
|
423
|
+
while current_id and current_id not in ancestor_ids:
|
|
424
|
+
ancestor_ids.add(current_id)
|
|
425
|
+
current = hypotheses.get(current_id) or {}
|
|
426
|
+
current_id = str(current.get("parent_hypothesis_id") or "").strip()
|
|
427
|
+
return ancestor_ids
|
|
428
|
+
|
|
429
|
+
|
|
430
|
+
def build_research_evidence_graph_from_records(
|
|
431
|
+
*,
|
|
432
|
+
goal_id: str,
|
|
433
|
+
hypotheses: list[dict[str, Any]],
|
|
434
|
+
evidence_events: list[dict[str, Any]],
|
|
435
|
+
metric_name: str,
|
|
436
|
+
metric_direction: str,
|
|
437
|
+
baseline_metric: float | None,
|
|
438
|
+
source_kind: str = "public_records",
|
|
439
|
+
) -> dict[str, Any]:
|
|
440
|
+
goal = _compact_public_token(goal_id, field="goal_id")
|
|
441
|
+
direction = _compact_public_token(metric_direction, field="metric.direction")
|
|
442
|
+
if direction not in METRIC_DIRECTIONS:
|
|
443
|
+
raise ValueError("metric.direction must be maximize or minimize")
|
|
444
|
+
name = _compact_public_token(metric_name, field="metric.name")
|
|
445
|
+
source = _compact_public_token(source_kind, field="source_kind")
|
|
446
|
+
hypotheses = [validate_research_hypothesis(dict(item)) for item in hypotheses]
|
|
447
|
+
events = [validate_research_evidence_event(dict(event)) for event in evidence_events]
|
|
448
|
+
baseline = _finite_float(baseline_metric, field="baseline_metric")
|
|
449
|
+
scored_events = [event for event in events if event["eval_status"] == "scored"]
|
|
450
|
+
best_dev = _best_metric(scored_events, split="dev", direction=direction)
|
|
451
|
+
best_holdout = _best_metric(scored_events, split="holdout", direction=direction)
|
|
452
|
+
hypotheses_by_id = {item["hypothesis_id"]: item for item in hypotheses}
|
|
453
|
+
events_by_hypothesis: dict[str, list[dict[str, Any]]] = {}
|
|
454
|
+
for event in events:
|
|
455
|
+
events_by_hypothesis.setdefault(event["hypothesis_id"], []).append(event)
|
|
456
|
+
nodes = []
|
|
457
|
+
for item in hypotheses:
|
|
458
|
+
item_events = events_by_hypothesis.get(item["hypothesis_id"], [])
|
|
459
|
+
item_scored_events = [event for event in item_events if event["eval_status"] == "scored"]
|
|
460
|
+
item_best_dev = _best_metric(item_scored_events, split="dev", direction=direction)
|
|
461
|
+
item_best_holdout = _best_metric(item_scored_events, split="holdout", direction=direction)
|
|
462
|
+
item_artifact_refs = sorted(
|
|
463
|
+
{
|
|
464
|
+
ref
|
|
465
|
+
for event in item_events
|
|
466
|
+
for ref in event.get("artifact_refs", [])
|
|
467
|
+
if ref
|
|
468
|
+
}
|
|
469
|
+
)
|
|
470
|
+
item_splits = sorted({event["split"] for event in item_events if event.get("split")})
|
|
471
|
+
item_negative_count = len([event for event in item_events if _is_negative_evidence_event(event)])
|
|
472
|
+
item_retry_count = len([event for event in item_events if _is_retry_evidence_event(event)])
|
|
473
|
+
item_failure_kind = (
|
|
474
|
+
_default_failure_kind(status=item["status"], events=item_events)
|
|
475
|
+
if item["status"] in {"contradicted", "retired", "needs_retry"}
|
|
476
|
+
or item_negative_count
|
|
477
|
+
else None
|
|
478
|
+
)
|
|
479
|
+
lineage_ids = _ancestor_hypothesis_ids(
|
|
480
|
+
item["hypothesis_id"],
|
|
481
|
+
hypotheses=hypotheses_by_id,
|
|
482
|
+
)
|
|
483
|
+
remediation_attempt_count = len(
|
|
484
|
+
[
|
|
485
|
+
event
|
|
486
|
+
for event in events
|
|
487
|
+
if event["hypothesis_id"] in lineage_ids
|
|
488
|
+
and event.get("remediation_attempt")
|
|
489
|
+
]
|
|
490
|
+
)
|
|
491
|
+
nodes.append(
|
|
492
|
+
{
|
|
493
|
+
"hypothesis_id": item["hypothesis_id"],
|
|
494
|
+
"parent_hypothesis_id": item["parent_hypothesis_id"],
|
|
495
|
+
"todo_id": item["todo_id"],
|
|
496
|
+
"claimed_by": item["claimed_by"],
|
|
497
|
+
"mechanism_family": item["mechanism_family"],
|
|
498
|
+
"hypothesis": item["hypothesis"],
|
|
499
|
+
"status": item["status"],
|
|
500
|
+
"grounding_refs": item["grounding_refs"],
|
|
501
|
+
"novelty_audit_ref": item["novelty_audit_ref"],
|
|
502
|
+
"artifact_refs": item_artifact_refs,
|
|
503
|
+
"splits": item_splits,
|
|
504
|
+
"evidence_event_count": len(item_events),
|
|
505
|
+
"best_dev_metric": item_best_dev,
|
|
506
|
+
"best_holdout_metric": item_best_holdout,
|
|
507
|
+
"dev_improved": _metric_improved(
|
|
508
|
+
value=item_best_dev,
|
|
509
|
+
baseline=baseline,
|
|
510
|
+
direction=direction,
|
|
511
|
+
),
|
|
512
|
+
"holdout_improved": _metric_improved(
|
|
513
|
+
value=item_best_holdout,
|
|
514
|
+
baseline=baseline,
|
|
515
|
+
direction=direction,
|
|
516
|
+
),
|
|
517
|
+
"negative_evidence_count": item_negative_count,
|
|
518
|
+
"needs_retry_count": item_retry_count,
|
|
519
|
+
"failure_kind": item_failure_kind,
|
|
520
|
+
"measurement_scope": _failure_measurement_scope(item_events),
|
|
521
|
+
"remediation_attempt_count": remediation_attempt_count,
|
|
522
|
+
"source_kind": source,
|
|
523
|
+
}
|
|
524
|
+
)
|
|
525
|
+
return {
|
|
526
|
+
"schema_version": RESEARCH_EVIDENCE_GRAPH_SCHEMA_VERSION,
|
|
527
|
+
"goal_id": goal,
|
|
528
|
+
"hypothesis_count": len(hypotheses),
|
|
529
|
+
"evidence_event_count": len(events),
|
|
530
|
+
"todo_ids": sorted({item["todo_id"] for item in hypotheses}),
|
|
531
|
+
"agent_ids": sorted({item["claimed_by"] for item in hypotheses}),
|
|
532
|
+
"metric": {
|
|
533
|
+
"name": name,
|
|
534
|
+
"direction": direction,
|
|
535
|
+
"baseline": baseline,
|
|
536
|
+
},
|
|
537
|
+
"baseline_metric": baseline,
|
|
538
|
+
"best_dev_metric": best_dev,
|
|
539
|
+
"best_holdout_metric": best_holdout,
|
|
540
|
+
"holdout_improved": _metric_improved(value=best_holdout, baseline=baseline, direction=direction),
|
|
541
|
+
"negative_evidence_count": len([event for event in events if _is_negative_evidence_event(event)]),
|
|
542
|
+
"needs_retry_count": len(
|
|
543
|
+
[event for event in events if _is_retry_evidence_event(event)]
|
|
544
|
+
) + len([item for item in hypotheses if item["status"] == "needs_retry"]),
|
|
545
|
+
"remediation_attempt_count": len(
|
|
546
|
+
[event for event in events if event.get("remediation_attempt")]
|
|
547
|
+
),
|
|
548
|
+
"nodes": nodes,
|
|
549
|
+
"source_kind": source,
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
|
|
553
|
+
def build_research_evidence_graph_from_rollout_events(
|
|
554
|
+
*,
|
|
555
|
+
goal_id: str,
|
|
556
|
+
rollout_events: list[dict[str, Any]],
|
|
557
|
+
) -> dict[str, Any]:
|
|
558
|
+
goal = _compact_public_token(goal_id, field="goal_id")
|
|
559
|
+
hypotheses_by_id: dict[str, dict[str, Any]] = {}
|
|
560
|
+
evidence_events: list[dict[str, Any]] = []
|
|
561
|
+
for event in rollout_events:
|
|
562
|
+
hypothesis = _research_hypothesis_from_rollout_event(event)
|
|
563
|
+
if hypothesis:
|
|
564
|
+
hypotheses_by_id[hypothesis["hypothesis_id"]] = hypothesis
|
|
565
|
+
continue
|
|
566
|
+
evidence = _research_evidence_from_rollout_event(event)
|
|
567
|
+
if evidence:
|
|
568
|
+
evidence_events.append(evidence)
|
|
569
|
+
|
|
570
|
+
events_by_hypothesis: dict[str, list[dict[str, Any]]] = {}
|
|
571
|
+
for evidence in evidence_events:
|
|
572
|
+
events_by_hypothesis.setdefault(evidence["hypothesis_id"], []).append(evidence)
|
|
573
|
+
for hypothesis_id, events in events_by_hypothesis.items():
|
|
574
|
+
if hypothesis_id not in hypotheses_by_id:
|
|
575
|
+
hypotheses_by_id[hypothesis_id] = _synthetic_hypothesis_from_evidence(events)
|
|
576
|
+
|
|
577
|
+
first_metric_event = evidence_events[0] if evidence_events else None
|
|
578
|
+
metric = first_metric_event["metric"] if first_metric_event else {}
|
|
579
|
+
return build_research_evidence_graph_from_records(
|
|
580
|
+
goal_id=goal,
|
|
581
|
+
hypotheses=list(hypotheses_by_id.values()),
|
|
582
|
+
evidence_events=evidence_events,
|
|
583
|
+
metric_name=metric.get("name") or "research_metric",
|
|
584
|
+
metric_direction=metric.get("direction") or "maximize",
|
|
585
|
+
baseline_metric=first_metric_event.get("baseline_metric") if first_metric_event else None,
|
|
586
|
+
source_kind=ROLLOUT_EVIDENCE_GRAPH_SOURCE_KIND,
|
|
587
|
+
)
|
|
588
|
+
|
|
589
|
+
|
|
590
|
+
def build_research_evidence_graph(fixture: dict[str, Any]) -> dict[str, Any]:
|
|
591
|
+
fixture = validate_auto_research_fixture(fixture)
|
|
592
|
+
contract = fixture["research_contract"]
|
|
593
|
+
return build_research_evidence_graph_from_records(
|
|
594
|
+
goal_id=contract["goal_id"],
|
|
595
|
+
hypotheses=fixture["hypotheses"],
|
|
596
|
+
evidence_events=fixture["evidence_events"],
|
|
597
|
+
metric_name=contract["metric"]["name"],
|
|
598
|
+
metric_direction=contract["metric"]["direction"],
|
|
599
|
+
baseline_metric=contract["metric"]["baseline"],
|
|
600
|
+
source_kind="public_fixture",
|
|
601
|
+
)
|
|
602
|
+
|
|
603
|
+
|
|
604
|
+
def build_research_decision_candidates(evidence_graph: dict[str, Any]) -> dict[str, list[dict[str, Any]]]:
|
|
605
|
+
graph = _json_obj(evidence_graph, field="evidence_graph")
|
|
606
|
+
metric = graph.get("metric") if isinstance(graph.get("metric"), dict) else {}
|
|
607
|
+
direction = str(metric.get("direction") or "maximize")
|
|
608
|
+
if direction not in METRIC_DIRECTIONS:
|
|
609
|
+
direction = "maximize"
|
|
610
|
+
baseline = _finite_float(metric.get("baseline"), field="evidence_graph.metric.baseline")
|
|
611
|
+
source_kind = _compact_optional_token(
|
|
612
|
+
graph.get("source_kind"),
|
|
613
|
+
field="evidence_graph.source_kind",
|
|
614
|
+
default="unknown_source",
|
|
615
|
+
)
|
|
616
|
+
promotion_candidates: list[dict[str, Any]] = []
|
|
617
|
+
dev_promotion_candidates: list[dict[str, Any]] = []
|
|
618
|
+
validated_promotion_candidates: list[dict[str, Any]] = []
|
|
619
|
+
retirement_candidates: list[dict[str, Any]] = []
|
|
620
|
+
for raw_node in graph.get("nodes") or []:
|
|
621
|
+
if not isinstance(raw_node, dict):
|
|
622
|
+
continue
|
|
623
|
+
hypothesis_id = _compact_public_token(raw_node.get("hypothesis_id"), field="node.hypothesis_id")
|
|
624
|
+
todo_id = _compact_public_token(raw_node.get("todo_id"), field="node.todo_id")
|
|
625
|
+
status = _compact_optional_token(raw_node.get("status"), field="node.status", default="active")
|
|
626
|
+
dev_metric = _finite_float(raw_node.get("best_dev_metric"), field="node.best_dev_metric")
|
|
627
|
+
holdout_metric = _finite_float(raw_node.get("best_holdout_metric"), field="node.best_holdout_metric")
|
|
628
|
+
negative_count = int(raw_node.get("negative_evidence_count") or 0)
|
|
629
|
+
evidence_count = int(raw_node.get("evidence_event_count") or 0)
|
|
630
|
+
dev_improved = bool(raw_node.get("dev_improved")) or _metric_improved(
|
|
631
|
+
value=dev_metric,
|
|
632
|
+
baseline=baseline,
|
|
633
|
+
direction=direction,
|
|
634
|
+
)
|
|
635
|
+
holdout_improved = bool(raw_node.get("holdout_improved")) or _metric_improved(
|
|
636
|
+
value=holdout_metric,
|
|
637
|
+
baseline=baseline,
|
|
638
|
+
direction=direction,
|
|
639
|
+
)
|
|
640
|
+
failure_kind = str(raw_node.get("failure_kind") or "")
|
|
641
|
+
retry_exhausted = status == "needs_retry" and failure_kind == "retry_exhausted"
|
|
642
|
+
if status in {"contradicted", "retired"} or negative_count > 0 or retry_exhausted:
|
|
643
|
+
if failure_kind not in RESEARCH_FAILURE_KINDS:
|
|
644
|
+
failure_kind = (
|
|
645
|
+
"guardrail_or_protected_boundary"
|
|
646
|
+
if status == "contradicted" and negative_count
|
|
647
|
+
else "mechanism_contradicted"
|
|
648
|
+
)
|
|
649
|
+
remediation_attempt_count = int(
|
|
650
|
+
raw_node.get("remediation_attempt_count") or 0
|
|
651
|
+
)
|
|
652
|
+
remediation_allowed = (
|
|
653
|
+
failure_kind == "data_or_measurement_gap"
|
|
654
|
+
and remediation_attempt_count < 1
|
|
655
|
+
)
|
|
656
|
+
retirement_candidates.append(
|
|
657
|
+
{
|
|
658
|
+
"hypothesis_id": hypothesis_id,
|
|
659
|
+
"todo_id": todo_id,
|
|
660
|
+
"status": status,
|
|
661
|
+
"negative_evidence_count": negative_count,
|
|
662
|
+
"evidence_event_count": evidence_count,
|
|
663
|
+
"reason": (
|
|
664
|
+
"retry_exhausted"
|
|
665
|
+
if retry_exhausted
|
|
666
|
+
else "negative_or_guardrail_evidence"
|
|
667
|
+
if negative_count
|
|
668
|
+
else f"status:{status}"
|
|
669
|
+
),
|
|
670
|
+
"failure_kind": failure_kind,
|
|
671
|
+
"measurement_scope": raw_node.get("measurement_scope"),
|
|
672
|
+
"remediation_attempt_count": remediation_attempt_count,
|
|
673
|
+
"remediation_attempt_limit": 1,
|
|
674
|
+
"remediation_allowed": remediation_allowed,
|
|
675
|
+
"next_outcome": (
|
|
676
|
+
"remediate_data_measurement"
|
|
677
|
+
if remediation_allowed
|
|
678
|
+
else "propose_failure_successor"
|
|
679
|
+
),
|
|
680
|
+
"source_kind": source_kind,
|
|
681
|
+
}
|
|
682
|
+
)
|
|
683
|
+
continue
|
|
684
|
+
if status in {"supported", "promoted"} or dev_improved:
|
|
685
|
+
requires = ["boundary_scan"]
|
|
686
|
+
requires.append("promotion_decision" if holdout_improved else "holdout_eval")
|
|
687
|
+
candidate = {
|
|
688
|
+
"hypothesis_id": hypothesis_id,
|
|
689
|
+
"todo_id": todo_id,
|
|
690
|
+
"status": status,
|
|
691
|
+
"dev_metric": dev_metric,
|
|
692
|
+
"holdout_metric": holdout_metric,
|
|
693
|
+
"evidence_event_count": evidence_count,
|
|
694
|
+
"requires": requires,
|
|
695
|
+
"source_kind": source_kind,
|
|
696
|
+
}
|
|
697
|
+
promotion_candidates.append(candidate)
|
|
698
|
+
if holdout_improved:
|
|
699
|
+
validated_promotion_candidates.append(candidate)
|
|
700
|
+
else:
|
|
701
|
+
dev_promotion_candidates.append(candidate)
|
|
702
|
+
return {
|
|
703
|
+
"dev_promotion_candidates": dev_promotion_candidates,
|
|
704
|
+
"validated_promotion_candidates": validated_promotion_candidates,
|
|
705
|
+
"promotion_candidates": promotion_candidates,
|
|
706
|
+
"retirement_candidates": retirement_candidates,
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
|
|
710
|
+
def build_research_failure_continuation_resolution(
|
|
711
|
+
decision_candidates: dict[str, list[dict[str, Any]]],
|
|
712
|
+
*,
|
|
713
|
+
selected_todo_id: str | None = None,
|
|
714
|
+
selected_lineage_todo_id: str | None = None,
|
|
715
|
+
allow_unbound_singleton: bool = False,
|
|
716
|
+
require_selected_failure_match: bool = False,
|
|
717
|
+
) -> dict[str, Any]:
|
|
718
|
+
candidates = [
|
|
719
|
+
dict(candidate)
|
|
720
|
+
for candidate in decision_candidates.get("retirement_candidates") or []
|
|
721
|
+
if isinstance(candidate, dict)
|
|
722
|
+
]
|
|
723
|
+
lineage_todo_id = str(selected_lineage_todo_id or "").strip()
|
|
724
|
+
selected_id = str(selected_todo_id or "").strip()
|
|
725
|
+
selection_bound = bool(lineage_todo_id) if require_selected_failure_match else bool(
|
|
726
|
+
lineage_todo_id or selected_id
|
|
727
|
+
)
|
|
728
|
+
selected_parent_todo_id = (
|
|
729
|
+
lineage_todo_id
|
|
730
|
+
if require_selected_failure_match
|
|
731
|
+
else lineage_todo_id or selected_id
|
|
732
|
+
)
|
|
733
|
+
matched = (
|
|
734
|
+
[
|
|
735
|
+
candidate
|
|
736
|
+
for candidate in candidates
|
|
737
|
+
if str(candidate.get("todo_id") or "").strip() == selected_parent_todo_id
|
|
738
|
+
]
|
|
739
|
+
if selection_bound
|
|
740
|
+
else []
|
|
741
|
+
)
|
|
742
|
+
candidate = (
|
|
743
|
+
matched[0]
|
|
744
|
+
if selection_bound and len(matched) == 1
|
|
745
|
+
else candidates[0]
|
|
746
|
+
if allow_unbound_singleton and not selection_bound and len(candidates) == 1
|
|
747
|
+
else None
|
|
748
|
+
)
|
|
749
|
+
continuation = (
|
|
750
|
+
{
|
|
751
|
+
"hypothesis_id": candidate["hypothesis_id"],
|
|
752
|
+
"source_todo_id": candidate["todo_id"],
|
|
753
|
+
"failure_kind": candidate["failure_kind"],
|
|
754
|
+
"measurement_scope": candidate.get("measurement_scope"),
|
|
755
|
+
"remediation_attempt_count": candidate["remediation_attempt_count"],
|
|
756
|
+
"remediation_attempt_limit": candidate["remediation_attempt_limit"],
|
|
757
|
+
"next_outcome": candidate["next_outcome"],
|
|
758
|
+
"monitor_allowed": False,
|
|
759
|
+
}
|
|
760
|
+
if candidate
|
|
761
|
+
else None
|
|
762
|
+
)
|
|
763
|
+
return {
|
|
764
|
+
"failure_continuation": continuation,
|
|
765
|
+
"retirement_candidate_count": len(candidates),
|
|
766
|
+
"matched_candidate_count": len(matched),
|
|
767
|
+
"lineage_todo_id": lineage_todo_id or None,
|
|
768
|
+
"selection_bound": selection_bound,
|
|
769
|
+
"ambiguous": not selection_bound and len(candidates) > 1,
|
|
770
|
+
"unresolved": require_selected_failure_match
|
|
771
|
+
and bool(candidates)
|
|
772
|
+
and (not lineage_todo_id or len(matched) != 1),
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
def build_research_failure_continuation(
|
|
777
|
+
decision_candidates: dict[str, list[dict[str, Any]]],
|
|
778
|
+
*,
|
|
779
|
+
selected_todo_id: str | None = None,
|
|
780
|
+
selected_lineage_todo_id: str | None = None,
|
|
781
|
+
allow_unbound_singleton: bool = True,
|
|
782
|
+
require_selected_failure_match: bool = False,
|
|
783
|
+
) -> dict[str, Any] | None:
|
|
784
|
+
resolution = build_research_failure_continuation_resolution(
|
|
785
|
+
decision_candidates,
|
|
786
|
+
selected_todo_id=selected_todo_id,
|
|
787
|
+
selected_lineage_todo_id=selected_lineage_todo_id,
|
|
788
|
+
allow_unbound_singleton=allow_unbound_singleton,
|
|
789
|
+
require_selected_failure_match=require_selected_failure_match,
|
|
790
|
+
)
|
|
791
|
+
return resolution["failure_continuation"]
|
|
792
|
+
|
|
793
|
+
|
|
794
|
+
def _holdout_metric_sequence_from_graph(evidence_graph: dict[str, Any]) -> list[float]:
|
|
795
|
+
sequence: list[float] = []
|
|
796
|
+
for raw_node in evidence_graph.get("nodes") or []:
|
|
797
|
+
if not isinstance(raw_node, dict):
|
|
798
|
+
continue
|
|
799
|
+
value = raw_node.get("best_holdout_metric")
|
|
800
|
+
if value is None or isinstance(value, bool):
|
|
801
|
+
continue
|
|
802
|
+
number = _finite_float(value, field="node.best_holdout_metric")
|
|
803
|
+
if number is not None:
|
|
804
|
+
sequence.append(number)
|
|
805
|
+
return sequence
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
def _metric_sequence_improvement_count(
|
|
809
|
+
sequence: list[float],
|
|
810
|
+
*,
|
|
811
|
+
baseline: float | None,
|
|
812
|
+
direction: str,
|
|
813
|
+
) -> int:
|
|
814
|
+
if baseline is None:
|
|
815
|
+
return 0
|
|
816
|
+
count = 0
|
|
817
|
+
previous = baseline
|
|
818
|
+
minimize = direction == "minimize"
|
|
819
|
+
for metric in sequence:
|
|
820
|
+
improved = metric < previous if minimize else metric > previous
|
|
821
|
+
if improved:
|
|
822
|
+
count += 1
|
|
823
|
+
previous = metric
|
|
824
|
+
return count
|
|
825
|
+
|
|
826
|
+
|
|
827
|
+
def build_auto_research_completion_status(
|
|
828
|
+
evidence_graph: dict[str, Any],
|
|
829
|
+
decision_candidates: dict[str, list[dict[str, Any]]] | None = None,
|
|
830
|
+
) -> dict[str, Any]:
|
|
831
|
+
graph = _json_obj(evidence_graph, field="evidence_graph")
|
|
832
|
+
decisions = decision_candidates or build_research_decision_candidates(graph)
|
|
833
|
+
metric = graph.get("metric") if isinstance(graph.get("metric"), dict) else {}
|
|
834
|
+
direction = str(metric.get("direction") or "maximize")
|
|
835
|
+
if direction not in METRIC_DIRECTIONS:
|
|
836
|
+
direction = "maximize"
|
|
837
|
+
baseline = _finite_float(metric.get("baseline"), field="evidence_graph.metric.baseline")
|
|
838
|
+
holdout_sequence = _holdout_metric_sequence_from_graph(graph)
|
|
839
|
+
holdout_improvement_count = _metric_sequence_improvement_count(
|
|
840
|
+
holdout_sequence,
|
|
841
|
+
baseline=baseline,
|
|
842
|
+
direction=direction,
|
|
843
|
+
)
|
|
844
|
+
required_holdout_improvement_count = AUTO_RESEARCH_REQUIRED_HOLDOUT_IMPROVEMENTS
|
|
845
|
+
dev_pending_count = len(decisions.get("dev_promotion_candidates") or [])
|
|
846
|
+
validated_count = len(decisions.get("validated_promotion_candidates") or [])
|
|
847
|
+
promotion_count = len(decisions.get("promotion_candidates") or [])
|
|
848
|
+
retirement_count = len(decisions.get("retirement_candidates") or [])
|
|
849
|
+
failure_resolution = build_research_failure_continuation_resolution(
|
|
850
|
+
decisions,
|
|
851
|
+
allow_unbound_singleton=True,
|
|
852
|
+
)
|
|
853
|
+
failure_continuation = failure_resolution["failure_continuation"]
|
|
854
|
+
|
|
855
|
+
status = "active"
|
|
856
|
+
next_action = "continue_frontier"
|
|
857
|
+
required_actions: list[str] = []
|
|
858
|
+
quiet_completion_allowed = False
|
|
859
|
+
reason = "frontier_still_active"
|
|
860
|
+
if validated_count and holdout_improvement_count >= required_holdout_improvement_count:
|
|
861
|
+
status = "target_reached"
|
|
862
|
+
next_action = "quiet_completion"
|
|
863
|
+
quiet_completion_allowed = True
|
|
864
|
+
reason = "required_holdout_improvements_reached"
|
|
865
|
+
elif dev_pending_count:
|
|
866
|
+
status = "holdout_eval_required"
|
|
867
|
+
next_action = "run_holdout_eval"
|
|
868
|
+
required_actions = ["holdout_eval", "boundary_scan"]
|
|
869
|
+
reason = "dev_promotion_candidate_pending_holdout"
|
|
870
|
+
elif validated_count or promotion_count:
|
|
871
|
+
status = "promotion_review_required"
|
|
872
|
+
next_action = "review_promotion_readiness"
|
|
873
|
+
required_actions = ["boundary_scan", "promotion_decision"]
|
|
874
|
+
reason = "validated_promotion_candidate_pending_decision"
|
|
875
|
+
elif retirement_count:
|
|
876
|
+
status = "failure_successor_required"
|
|
877
|
+
next_action = str(
|
|
878
|
+
(failure_continuation or {}).get("next_outcome")
|
|
879
|
+
or "propose_failure_successor"
|
|
880
|
+
)
|
|
881
|
+
required_actions = [next_action]
|
|
882
|
+
reason = "retirement_candidate_requires_successor_or_exhaustion"
|
|
883
|
+
|
|
884
|
+
return {
|
|
885
|
+
"schema_version": AUTO_RESEARCH_COMPLETION_STATUS_SCHEMA_VERSION,
|
|
886
|
+
"status": status,
|
|
887
|
+
"next_action": next_action,
|
|
888
|
+
"reason": reason,
|
|
889
|
+
"quiet_completion_allowed": quiet_completion_allowed,
|
|
890
|
+
"required_actions": required_actions,
|
|
891
|
+
"required_holdout_improvement_count": required_holdout_improvement_count,
|
|
892
|
+
"holdout_improvement_count": holdout_improvement_count,
|
|
893
|
+
"holdout_metric_sequence": holdout_sequence,
|
|
894
|
+
"validated_promotion_candidate_count": validated_count,
|
|
895
|
+
"dev_candidate_pending_holdout_count": dev_pending_count,
|
|
896
|
+
"promotion_candidate_count": promotion_count,
|
|
897
|
+
"retirement_candidate_count": retirement_count,
|
|
898
|
+
"failure_continuation": failure_continuation,
|
|
899
|
+
"failure_continuation_ambiguous": failure_resolution["ambiguous"],
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
|
|
903
|
+
def build_auto_research_projection(
|
|
904
|
+
fixture: dict[str, Any],
|
|
905
|
+
*,
|
|
906
|
+
agent_id: str,
|
|
907
|
+
) -> dict[str, Any]:
|
|
908
|
+
fixture = validate_auto_research_fixture(fixture)
|
|
909
|
+
agent = _compact_public_token(agent_id, field="agent_id")
|
|
910
|
+
contract = fixture["research_contract"]
|
|
911
|
+
hypotheses = fixture["hypotheses"]
|
|
912
|
+
evidence_graph = build_research_evidence_graph(fixture)
|
|
913
|
+
decision_candidates = build_research_decision_candidates(evidence_graph)
|
|
914
|
+
completion = build_auto_research_completion_status(evidence_graph, decision_candidates)
|
|
915
|
+
|
|
916
|
+
runnable_statuses = {"active", "needs_retry"}
|
|
917
|
+
selected = None
|
|
918
|
+
blocked: list[dict[str, Any]] = []
|
|
919
|
+
runnable: list[dict[str, Any]] = []
|
|
920
|
+
for item in hypotheses:
|
|
921
|
+
item_summary = {
|
|
922
|
+
"hypothesis_id": item["hypothesis_id"],
|
|
923
|
+
"todo_id": item["todo_id"],
|
|
924
|
+
"claimed_by": item["claimed_by"],
|
|
925
|
+
"status": item["status"],
|
|
926
|
+
"mechanism_family": item["mechanism_family"],
|
|
927
|
+
}
|
|
928
|
+
if item["claimed_by"] == agent and item["status"] in runnable_statuses and not item["blocked_by"]:
|
|
929
|
+
runnable.append(item_summary | {"allowed_action": "run_dev_attempt"})
|
|
930
|
+
selected = selected or runnable[-1]
|
|
931
|
+
elif item["claimed_by"] != agent and item["status"] in runnable_statuses:
|
|
932
|
+
blocked.append(item_summary | {"blocked_by": f"claimed_by:{item['claimed_by']}"})
|
|
933
|
+
elif item["blocked_by"]:
|
|
934
|
+
blocked.append(item_summary | {"blocked_by": ",".join(item["blocked_by"])})
|
|
935
|
+
|
|
936
|
+
frontier = {
|
|
937
|
+
"schema_version": RESEARCH_FRONTIER_SCHEMA_VERSION,
|
|
938
|
+
"goal_id": contract["goal_id"],
|
|
939
|
+
"agent_id": agent,
|
|
940
|
+
"selected": selected,
|
|
941
|
+
"runnable": runnable,
|
|
942
|
+
"blocked": blocked,
|
|
943
|
+
"promotion_candidates": decision_candidates["promotion_candidates"],
|
|
944
|
+
"retirement_candidates": decision_candidates["retirement_candidates"],
|
|
945
|
+
"completion": completion,
|
|
946
|
+
}
|
|
947
|
+
return {
|
|
948
|
+
"ok": True,
|
|
949
|
+
"schema_version": AUTO_RESEARCH_PROJECTION_SCHEMA_VERSION,
|
|
950
|
+
"source_schema_version": fixture["schema_version"],
|
|
951
|
+
"frontier": frontier,
|
|
952
|
+
"evidence_graph": evidence_graph,
|
|
953
|
+
"completion": completion,
|
|
954
|
+
"public_boundary": {
|
|
955
|
+
"raw_logs_recorded": False,
|
|
956
|
+
"private_artifacts_recorded": False,
|
|
957
|
+
"source": "public_fixture",
|
|
958
|
+
},
|
|
959
|
+
}
|
|
960
|
+
|
|
961
|
+
|
|
962
|
+
def build_live_auto_research_projection(
|
|
963
|
+
*,
|
|
964
|
+
goal_id: str,
|
|
965
|
+
agent_id: str,
|
|
966
|
+
quota_payload: dict[str, Any],
|
|
967
|
+
rollout_events: list[dict[str, Any]] | None = None,
|
|
968
|
+
) -> dict[str, Any]:
|
|
969
|
+
goal = _compact_public_token(goal_id, field="goal_id")
|
|
970
|
+
agent = _compact_public_token(agent_id, field="agent_id")
|
|
971
|
+
if not quota_payload.get("ok"):
|
|
972
|
+
raise ValueError("quota payload must be ok for live auto-research projection")
|
|
973
|
+
|
|
974
|
+
runnable_candidates, blocked_candidates = _quota_payload_todo_candidates(quota_payload)
|
|
975
|
+
selected_raw = quota_payload.get("agent_lane_next_action")
|
|
976
|
+
selected = None
|
|
977
|
+
if (
|
|
978
|
+
isinstance(selected_raw, dict)
|
|
979
|
+
and selected_raw.get("todo_id")
|
|
980
|
+
and _claimed_by_current_or_unclaimed(selected_raw, agent_id=agent)
|
|
981
|
+
):
|
|
982
|
+
selected = _todo_frontier_item(selected_raw, default_agent_id=agent)
|
|
983
|
+
else:
|
|
984
|
+
for item in runnable_candidates:
|
|
985
|
+
if _claimed_by_current_or_unclaimed(item, agent_id=agent):
|
|
986
|
+
selected = _todo_frontier_item(item, default_agent_id=agent)
|
|
987
|
+
break
|
|
988
|
+
|
|
989
|
+
runnable: list[dict[str, Any]] = []
|
|
990
|
+
seen_todos: set[str] = set()
|
|
991
|
+
for item in runnable_candidates:
|
|
992
|
+
if not item.get("todo_id") or not _claimed_by_current_or_unclaimed(item, agent_id=agent):
|
|
993
|
+
continue
|
|
994
|
+
summary = _todo_frontier_item(item, default_agent_id=agent)
|
|
995
|
+
if summary["todo_id"] in seen_todos:
|
|
996
|
+
continue
|
|
997
|
+
seen_todos.add(summary["todo_id"])
|
|
998
|
+
runnable.append(summary)
|
|
999
|
+
|
|
1000
|
+
blocked: list[dict[str, Any]] = []
|
|
1001
|
+
other_claimed_context = [
|
|
1002
|
+
item
|
|
1003
|
+
for item in runnable_candidates
|
|
1004
|
+
if item.get("todo_id") and not _claimed_by_current_or_unclaimed(item, agent_id=agent)
|
|
1005
|
+
]
|
|
1006
|
+
for item in [*other_claimed_context, *blocked_candidates][:12]:
|
|
1007
|
+
if not item.get("todo_id"):
|
|
1008
|
+
continue
|
|
1009
|
+
claimed_by = item.get("claimed_by")
|
|
1010
|
+
status = item.get("status") or "blocked"
|
|
1011
|
+
reason = f"claimed_by:{claimed_by}" if claimed_by and claimed_by != agent else f"status:{status}"
|
|
1012
|
+
blocked.append(_todo_frontier_item(item, default_agent_id=agent, blocked_by=reason))
|
|
1013
|
+
|
|
1014
|
+
todo_graph = {
|
|
1015
|
+
"schema_version": RESEARCH_EVIDENCE_GRAPH_SCHEMA_VERSION,
|
|
1016
|
+
"goal_id": goal,
|
|
1017
|
+
"hypothesis_count": len(runnable) + len(blocked),
|
|
1018
|
+
"evidence_event_count": 0,
|
|
1019
|
+
"todo_ids": sorted({item["todo_id"] for item in [*runnable, *blocked]}),
|
|
1020
|
+
"agent_ids": sorted({item["claimed_by"] for item in [*runnable, *blocked]}),
|
|
1021
|
+
"metric": {
|
|
1022
|
+
"name": "runnable_hypotheses",
|
|
1023
|
+
"direction": "maximize",
|
|
1024
|
+
"baseline": 0.0,
|
|
1025
|
+
},
|
|
1026
|
+
"baseline_metric": None,
|
|
1027
|
+
"best_dev_metric": None,
|
|
1028
|
+
"best_holdout_metric": None,
|
|
1029
|
+
"holdout_improved": False,
|
|
1030
|
+
"negative_evidence_count": 0,
|
|
1031
|
+
"needs_retry_count": 0,
|
|
1032
|
+
"nodes": [
|
|
1033
|
+
{
|
|
1034
|
+
"hypothesis_id": item["hypothesis_id"],
|
|
1035
|
+
"parent_hypothesis_id": None,
|
|
1036
|
+
"todo_id": item["todo_id"],
|
|
1037
|
+
"claimed_by": item["claimed_by"],
|
|
1038
|
+
"status": item["status"],
|
|
1039
|
+
"source_kind": item["source_kind"],
|
|
1040
|
+
}
|
|
1041
|
+
for item in [*runnable, *blocked]
|
|
1042
|
+
],
|
|
1043
|
+
"source_kind": "loopx_live_quota_status",
|
|
1044
|
+
}
|
|
1045
|
+
rollout_graph = build_research_evidence_graph_from_rollout_events(
|
|
1046
|
+
goal_id=goal,
|
|
1047
|
+
rollout_events=rollout_events or [],
|
|
1048
|
+
)
|
|
1049
|
+
evidence_graph = (
|
|
1050
|
+
rollout_graph
|
|
1051
|
+
if rollout_graph["evidence_event_count"] or rollout_graph["hypothesis_count"]
|
|
1052
|
+
else todo_graph
|
|
1053
|
+
)
|
|
1054
|
+
decisions = build_research_decision_candidates(evidence_graph)
|
|
1055
|
+
completion = build_auto_research_completion_status(evidence_graph, decisions)
|
|
1056
|
+
frontier = {
|
|
1057
|
+
"schema_version": RESEARCH_FRONTIER_SCHEMA_VERSION,
|
|
1058
|
+
"goal_id": goal,
|
|
1059
|
+
"agent_id": agent,
|
|
1060
|
+
"selected": selected,
|
|
1061
|
+
"runnable": runnable,
|
|
1062
|
+
"blocked": blocked,
|
|
1063
|
+
"promotion_candidates": decisions["promotion_candidates"],
|
|
1064
|
+
"retirement_candidates": decisions["retirement_candidates"],
|
|
1065
|
+
"completion": completion,
|
|
1066
|
+
"source_kind": "loopx_live_quota_status",
|
|
1067
|
+
}
|
|
1068
|
+
return {
|
|
1069
|
+
"ok": True,
|
|
1070
|
+
"schema_version": AUTO_RESEARCH_PROJECTION_SCHEMA_VERSION,
|
|
1071
|
+
"source_schema_version": "loopx_live_quota_status_v0",
|
|
1072
|
+
"frontier": frontier,
|
|
1073
|
+
"evidence_graph": evidence_graph,
|
|
1074
|
+
"decision_candidates": decisions,
|
|
1075
|
+
"completion": completion,
|
|
1076
|
+
"public_boundary": {
|
|
1077
|
+
"raw_logs_recorded": False,
|
|
1078
|
+
"private_artifacts_recorded": False,
|
|
1079
|
+
"source": (
|
|
1080
|
+
"live_quota_status_and_rollout_event_log"
|
|
1081
|
+
if evidence_graph.get("source_kind") == ROLLOUT_EVIDENCE_GRAPH_SOURCE_KIND
|
|
1082
|
+
else "live_quota_status_projection"
|
|
1083
|
+
),
|
|
1084
|
+
},
|
|
1085
|
+
}
|