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,2056 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import hashlib
|
|
4
|
+
import json
|
|
5
|
+
import re
|
|
6
|
+
import shlex
|
|
7
|
+
from pathlib import Path
|
|
8
|
+
from typing import Any
|
|
9
|
+
|
|
10
|
+
from harbor.agents.installed.codex import Codex
|
|
11
|
+
from harbor.environments.base import BaseEnvironment
|
|
12
|
+
from harbor.models.agent.context import AgentContext
|
|
13
|
+
|
|
14
|
+
from loopx.benchmark import (
|
|
15
|
+
TERMINAL_BENCH_CODEX_WORKER_CLI_BRIDGE_SURFACE,
|
|
16
|
+
TERMINAL_BENCH_CODEX_INSTALL_STRATEGIES,
|
|
17
|
+
TERMINAL_BENCH_CODEX_INSTALL_STRATEGY_REQUIRE_EXISTING,
|
|
18
|
+
TERMINAL_BENCH_CODEX_INSTALL_STRATEGY_RUNTIME_INSTALL_IF_MISSING,
|
|
19
|
+
TERMINAL_BENCH_CODEX_GOAL_MODE_BASELINE_MODE,
|
|
20
|
+
TERMINAL_BENCH_CODEX_GOAL_MODE_BASELINE_SURFACE,
|
|
21
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_AVAILABLE,
|
|
22
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_FULL,
|
|
23
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE,
|
|
24
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODES,
|
|
25
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_COMMANDS,
|
|
26
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_VERSION,
|
|
27
|
+
TERMINAL_BENCH_LOOPX_ACTIVE_USER_OBSERVE_COMMAND,
|
|
28
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CALL_POLICY_MODE,
|
|
29
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CALL_POLICY_VERSION,
|
|
30
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CONTRACT_VERSION,
|
|
31
|
+
TERMINAL_BENCH_LOOPX_COUNTER_TRACE_COMMANDS,
|
|
32
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_DEFAULT_REQUIRED_CALLS,
|
|
33
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_OPTIONAL_CONTEXT_CALLS,
|
|
34
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_REQUIRED_CALL_MINIMUM,
|
|
35
|
+
TERMINAL_BENCH_LOOPX_INTERFACE_SURFACE,
|
|
36
|
+
TERMINAL_BENCH_HARDENED_CODEX_BASELINE_MODES,
|
|
37
|
+
TERMINAL_BENCH_HARDENED_CODEX_BASELINE_SURFACE,
|
|
38
|
+
TERMINAL_BENCH_WORKER_CODEX_MATERIALIZATION_STRATEGIES,
|
|
39
|
+
TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_FILE,
|
|
40
|
+
TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_SCHEMA,
|
|
41
|
+
build_terminal_bench_loopx_access_packet,
|
|
42
|
+
build_terminal_bench_loopx_interaction_counters,
|
|
43
|
+
build_terminal_bench_single_agent_episode_policy,
|
|
44
|
+
)
|
|
45
|
+
from loopx.benchmark_case_state import (
|
|
46
|
+
BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
47
|
+
benchmark_case_active_state_path,
|
|
48
|
+
benchmark_case_active_state_seed_text,
|
|
49
|
+
benchmark_case_active_state_write_command,
|
|
50
|
+
benchmark_case_goal_id,
|
|
51
|
+
)
|
|
52
|
+
from loopx.worker_bridge import (
|
|
53
|
+
ACTIVE_USER_INTERVENTION_CHANNEL_SURFACE,
|
|
54
|
+
DEFAULT_WORKER_BRIDGE_ACTIVE_USER_FEED_JSONL,
|
|
55
|
+
DEFAULT_WORKER_BRIDGE_ACTIVE_USER_OBSERVATION_JSON,
|
|
56
|
+
DEFAULT_WORKER_BRIDGE_BENCHMARK_RUN_JSON,
|
|
57
|
+
DEFAULT_WORKER_BRIDGE_COUNTER_TRACE_JSON,
|
|
58
|
+
DEFAULT_WORKER_BRIDGE_TRACE_DIR,
|
|
59
|
+
LOOPX_PROJECT_ROOT_PLACEHOLDER,
|
|
60
|
+
LOOPX_RUNTIME_ROOT_PLACEHOLDER,
|
|
61
|
+
WORKER_BRIDGE_BENCHMARK_RUN_WRITEBACK_CONTRACT_VERSION,
|
|
62
|
+
build_worker_bridge_benchmark_run_from_counters,
|
|
63
|
+
build_worker_bridge_command_prefix,
|
|
64
|
+
build_worker_bridge_python_runtime_preflight_command,
|
|
65
|
+
worker_bridge_cli_call_total_from_interaction_counters,
|
|
66
|
+
write_worker_bridge_benchmark_run_file,
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
CODEX_LOOPX_MODE = "codex_loopx"
|
|
70
|
+
CODEX_GOAL_MODE_BASELINE_MODE = TERMINAL_BENCH_CODEX_GOAL_MODE_BASELINE_MODE
|
|
71
|
+
LOOPX_MANAGED_CODEX_MODE = "loopx_managed_codex"
|
|
72
|
+
LOOPX_MANAGED_CODEX_POLICY_VERSION = "loopx_terminal_bench_policy_v0"
|
|
73
|
+
LOOPX_MANAGED_CODEX_BEHAVIOR_SPEC_ID = (
|
|
74
|
+
"terminal_bench_loopx_managed_codex_v0"
|
|
75
|
+
)
|
|
76
|
+
CODEX_SESSION_TOKEN_COUNT_USAGE_SOURCE = "codex_cli_session_token_count_event"
|
|
77
|
+
LOOPX_COUNTER_TRACE_SCHEMA_VERSION = (
|
|
78
|
+
"terminal_bench_loopx_counter_trace_v0"
|
|
79
|
+
)
|
|
80
|
+
TERMINAL_BENCH_CASE_GOAL_ID = benchmark_case_goal_id("terminal-bench")
|
|
81
|
+
TERMINAL_BENCH_CASE_STATE_PATH = benchmark_case_active_state_path(
|
|
82
|
+
TERMINAL_BENCH_CASE_GOAL_ID
|
|
83
|
+
)
|
|
84
|
+
DEFAULT_LOOPX_WORKER_COMMAND_PREFIX = build_worker_bridge_command_prefix()
|
|
85
|
+
DEFAULT_LOOPX_WORKER_RUNTIME_PREFLIGHT_COMMAND = (
|
|
86
|
+
build_worker_bridge_python_runtime_preflight_command()
|
|
87
|
+
)
|
|
88
|
+
DEFAULT_LOOPX_WORKER_REGISTRY_ARG = (
|
|
89
|
+
LOOPX_RUNTIME_ROOT_PLACEHOLDER + "/registry.global.json"
|
|
90
|
+
)
|
|
91
|
+
DEFAULT_LOOPX_WORKER_SCAN_PATH = (
|
|
92
|
+
LOOPX_PROJECT_ROOT_PLACEHOLDER + "/loopx/benchmark.py"
|
|
93
|
+
)
|
|
94
|
+
CODEX_REQUIRE_EXISTING_BLOCKER_NOT_ON_PATH = "codex_cli_not_on_path"
|
|
95
|
+
CODEX_REQUIRE_EXISTING_BLOCKER_VERSION_PROBE_FAILED = (
|
|
96
|
+
"codex_cli_version_probe_failed"
|
|
97
|
+
)
|
|
98
|
+
CODEX_REQUIRE_EXISTING_BLOCKER_SYMLINK_REPAIR_FAILED = (
|
|
99
|
+
"codex_cli_symlink_repair_failed"
|
|
100
|
+
)
|
|
101
|
+
DEFAULT_CODEX_PREFLIGHT_TIMEOUT_SEC = 45
|
|
102
|
+
UNRESOLVED_ANGLE_PLACEHOLDER_RE = re.compile(r"<[^>\s]+>")
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def _concrete_active_user_observe_command(
|
|
106
|
+
command: str,
|
|
107
|
+
*,
|
|
108
|
+
worker_start_seq: int = 0,
|
|
109
|
+
) -> str | None:
|
|
110
|
+
"""Return a worker-runnable active-user observe command when it is concrete."""
|
|
111
|
+
|
|
112
|
+
text = str(command or "").strip()
|
|
113
|
+
if not text or text in {
|
|
114
|
+
"<active-user-observe-command>",
|
|
115
|
+
"<active-user-observe-command-redacted>",
|
|
116
|
+
}:
|
|
117
|
+
return None
|
|
118
|
+
text = text.replace("<worker-start-seq>", str(worker_start_seq))
|
|
119
|
+
if UNRESOLVED_ANGLE_PLACEHOLDER_RE.search(text):
|
|
120
|
+
return None
|
|
121
|
+
return text
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def build_private_active_user_observe_instruction(
|
|
125
|
+
*,
|
|
126
|
+
enabled: bool,
|
|
127
|
+
observe_command: str,
|
|
128
|
+
observation_json: str,
|
|
129
|
+
counter_trace_json: str,
|
|
130
|
+
goal_id: str,
|
|
131
|
+
mode: str,
|
|
132
|
+
classification: str,
|
|
133
|
+
) -> str:
|
|
134
|
+
"""Build the private worker-only active-user observe checkpoint."""
|
|
135
|
+
|
|
136
|
+
if not enabled:
|
|
137
|
+
return ""
|
|
138
|
+
concrete_command = _concrete_active_user_observe_command(
|
|
139
|
+
observe_command,
|
|
140
|
+
worker_start_seq=0,
|
|
141
|
+
)
|
|
142
|
+
if concrete_command is None:
|
|
143
|
+
return (
|
|
144
|
+
"\nActive-user observe checkpoint for this case:\n"
|
|
145
|
+
"- The active-user channel is enabled, but no runnable private observe command was provided.\n"
|
|
146
|
+
"- Do not claim active-user observation unless a concrete observe command is available and executed.\n\n"
|
|
147
|
+
)
|
|
148
|
+
trace_example = {
|
|
149
|
+
"kind": "loopx_cli_call",
|
|
150
|
+
"command": TERMINAL_BENCH_LOOPX_ACTIVE_USER_OBSERVE_COMMAND,
|
|
151
|
+
"ok": True,
|
|
152
|
+
"goal_id": goal_id,
|
|
153
|
+
"mode": mode,
|
|
154
|
+
"classification": classification,
|
|
155
|
+
}
|
|
156
|
+
return (
|
|
157
|
+
"\nActive-user observe checkpoint for this case:\n"
|
|
158
|
+
"- The active-user channel is enabled. This private worker checkpoint supplies the runnable observe command; the public access packet may redact it.\n"
|
|
159
|
+
"- Before broad task work, run this exact command once:\n"
|
|
160
|
+
f" {concrete_command}\n"
|
|
161
|
+
"- If no post-start intervention is observed, run the same observe command once more before final validation or a terminal blocker decision.\n"
|
|
162
|
+
f"- Read {observation_json} after the command. If observed_after_worker_start is true, apply only the compact latest_intervention.message and boundary fields.\n"
|
|
163
|
+
f"- Append one compact trace row to {counter_trace_json} for each observe attempt; use command={TERMINAL_BENCH_LOOPX_ACTIVE_USER_OBSERVE_COMMAND} and public-safe fields like:\n"
|
|
164
|
+
f" {json.dumps(trace_example, sort_keys=True)}\n"
|
|
165
|
+
"- Do not paste raw feed contents, raw paths, credentials, hidden tests, expected solutions, or transcripts into the final answer.\n\n"
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def build_codex_goal_mode_baseline_instruction(task_instruction: str) -> str:
|
|
170
|
+
"""Build a /goal-prefixed baseline prompt without LoopX state.
|
|
171
|
+
|
|
172
|
+
This requests goal-mode-like behavior. Native Codex CLI goal-mode
|
|
173
|
+
confirmation requires separate interactive slash-command or goal-state
|
|
174
|
+
evidence.
|
|
175
|
+
"""
|
|
176
|
+
|
|
177
|
+
return (
|
|
178
|
+
"/goal Complete the following Terminal-Bench task. Keep working until "
|
|
179
|
+
"the task is done, validated, or blocked by the benchmark environment.\n\n"
|
|
180
|
+
f"{task_instruction}"
|
|
181
|
+
)
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
def build_managed_terminal_bench_instruction(
|
|
185
|
+
task_instruction: str,
|
|
186
|
+
*,
|
|
187
|
+
policy_version: str = LOOPX_MANAGED_CODEX_POLICY_VERSION,
|
|
188
|
+
behavior_spec_id: str = LOOPX_MANAGED_CODEX_BEHAVIOR_SPEC_ID,
|
|
189
|
+
ablation_mode: str = "loopx_managed",
|
|
190
|
+
loopx_mode: str = LOOPX_MANAGED_CODEX_MODE,
|
|
191
|
+
goal_id: str = "<goal-id>",
|
|
192
|
+
loopx_access_packet_mode: str = (
|
|
193
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_FULL
|
|
194
|
+
),
|
|
195
|
+
loopx_cli_bridge_enabled: bool = False,
|
|
196
|
+
loopx_command_prefix: str = DEFAULT_LOOPX_WORKER_COMMAND_PREFIX,
|
|
197
|
+
loopx_registry_arg: str = DEFAULT_LOOPX_WORKER_REGISTRY_ARG,
|
|
198
|
+
loopx_runtime_root_arg: str = LOOPX_RUNTIME_ROOT_PLACEHOLDER,
|
|
199
|
+
loopx_scan_path: str = DEFAULT_LOOPX_WORKER_SCAN_PATH,
|
|
200
|
+
loopx_benchmark_run_json: str = DEFAULT_WORKER_BRIDGE_BENCHMARK_RUN_JSON,
|
|
201
|
+
loopx_counter_trace_json: str = DEFAULT_WORKER_BRIDGE_COUNTER_TRACE_JSON,
|
|
202
|
+
loopx_classification: str = "<classification>",
|
|
203
|
+
loopx_append_execute_enabled: bool = False,
|
|
204
|
+
loopx_active_user_intervention_enabled: bool = False,
|
|
205
|
+
loopx_active_user_feed_jsonl: str = DEFAULT_WORKER_BRIDGE_ACTIVE_USER_FEED_JSONL,
|
|
206
|
+
loopx_active_user_observation_json: str = DEFAULT_WORKER_BRIDGE_ACTIVE_USER_OBSERVATION_JSON,
|
|
207
|
+
loopx_active_user_observe_command: str = "<active-user-observe-command>",
|
|
208
|
+
loopx_active_user_channel_surface: str = ACTIVE_USER_INTERVENTION_CHANNEL_SURFACE,
|
|
209
|
+
loopx_case_state_path: str = TERMINAL_BENCH_CASE_STATE_PATH,
|
|
210
|
+
loopx_case_state_schema_version: str = BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
211
|
+
loopx_case_state_required: bool = True,
|
|
212
|
+
) -> str:
|
|
213
|
+
"""Wrap a benchmark task with the minimal LoopX managed policy."""
|
|
214
|
+
|
|
215
|
+
if (
|
|
216
|
+
loopx_mode in TERMINAL_BENCH_HARDENED_CODEX_BASELINE_MODES
|
|
217
|
+
and loopx_access_packet_mode
|
|
218
|
+
== TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
219
|
+
):
|
|
220
|
+
return task_instruction
|
|
221
|
+
if (
|
|
222
|
+
loopx_mode == CODEX_GOAL_MODE_BASELINE_MODE
|
|
223
|
+
and loopx_access_packet_mode
|
|
224
|
+
== TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
225
|
+
):
|
|
226
|
+
return build_codex_goal_mode_baseline_instruction(task_instruction)
|
|
227
|
+
|
|
228
|
+
access_packet = ""
|
|
229
|
+
access_packet_enabled = (
|
|
230
|
+
loopx_mode == CODEX_LOOPX_MODE
|
|
231
|
+
and loopx_access_packet_mode
|
|
232
|
+
!= TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
233
|
+
)
|
|
234
|
+
if access_packet_enabled:
|
|
235
|
+
access_packet_body = build_terminal_bench_loopx_access_packet(
|
|
236
|
+
goal_id=goal_id,
|
|
237
|
+
packet_mode=loopx_access_packet_mode,
|
|
238
|
+
cli_bridge_available=loopx_cli_bridge_enabled,
|
|
239
|
+
command_prefix=loopx_command_prefix,
|
|
240
|
+
registry_arg=loopx_registry_arg,
|
|
241
|
+
runtime_root_arg=loopx_runtime_root_arg,
|
|
242
|
+
scan_path=loopx_scan_path,
|
|
243
|
+
benchmark_run_json=loopx_benchmark_run_json,
|
|
244
|
+
counter_trace_json=loopx_counter_trace_json,
|
|
245
|
+
classification=loopx_classification,
|
|
246
|
+
append_execute_enabled=loopx_append_execute_enabled,
|
|
247
|
+
active_user_intervention_enabled=(
|
|
248
|
+
loopx_active_user_intervention_enabled
|
|
249
|
+
),
|
|
250
|
+
active_user_feed_jsonl=loopx_active_user_feed_jsonl,
|
|
251
|
+
active_user_observation_json=loopx_active_user_observation_json,
|
|
252
|
+
active_user_observe_command=loopx_active_user_observe_command,
|
|
253
|
+
active_user_channel_surface=loopx_active_user_channel_surface,
|
|
254
|
+
)
|
|
255
|
+
access_packet = (
|
|
256
|
+
"\nLoopX access packet for this case:\n\n"
|
|
257
|
+
"----- LOOPX ACCESS PACKET -----\n"
|
|
258
|
+
f"{access_packet_body}\n"
|
|
259
|
+
"----- END LOOPX ACCESS PACKET -----\n\n"
|
|
260
|
+
)
|
|
261
|
+
active_user_observe_instruction = build_private_active_user_observe_instruction(
|
|
262
|
+
enabled=(
|
|
263
|
+
access_packet_enabled
|
|
264
|
+
and loopx_cli_bridge_enabled
|
|
265
|
+
and loopx_active_user_intervention_enabled
|
|
266
|
+
),
|
|
267
|
+
observe_command=loopx_active_user_observe_command,
|
|
268
|
+
observation_json=loopx_active_user_observation_json,
|
|
269
|
+
counter_trace_json=loopx_counter_trace_json,
|
|
270
|
+
goal_id=goal_id,
|
|
271
|
+
mode=loopx_mode,
|
|
272
|
+
classification=loopx_classification,
|
|
273
|
+
)
|
|
274
|
+
case_state_instruction = ""
|
|
275
|
+
if loopx_case_state_required and loopx_case_state_path:
|
|
276
|
+
case_state_instruction = (
|
|
277
|
+
"LoopX benchmark case-state contract:\n"
|
|
278
|
+
f"- Canonical active state path: `{loopx_case_state_path}`.\n"
|
|
279
|
+
f"- Active state schema: `{loopx_case_state_schema_version}`.\n"
|
|
280
|
+
"- The runner initializes this file before the Codex worker starts.\n"
|
|
281
|
+
"- Read and maintain this case-local active state as the control surface; "
|
|
282
|
+
"do not use benchmark-specific surrogate state files.\n\n"
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
return (
|
|
286
|
+
"You are running one Terminal-Bench task under LoopX managed Codex mode.\n"
|
|
287
|
+
f"Policy version: {policy_version}.\n"
|
|
288
|
+
f"Behavior spec: {behavior_spec_id}.\n"
|
|
289
|
+
f"Ablation mode: {ablation_mode}.\n\n"
|
|
290
|
+
"LoopX operating rules for this case:\n"
|
|
291
|
+
"- Solve the benchmark task normally inside the provided case environment.\n"
|
|
292
|
+
"- Keep all raw traces, credentials, auth files, host paths, and private logs out of final answers.\n"
|
|
293
|
+
"- Do not upload, publish, share, or claim leaderboard evidence.\n"
|
|
294
|
+
"- Prefer small verifiable edits, recheck the result after meaningful changes, and report a concise blocker if the task cannot be completed.\n"
|
|
295
|
+
"- If a LoopX CLI bridge packet is present, treat command lines as templates: replace placeholders before execution, quote paths as single argv values, and do not run commands containing unresolved angle-bracket placeholders.\n"
|
|
296
|
+
"- Write the compact LoopX case result only after final validation and cleanup, or after a terminal blocker decision; the runner still performs guaranteed final archive writeback.\n"
|
|
297
|
+
"- Treat this as a model plus harness pair; do not present it as a native Codex baseline.\n\n"
|
|
298
|
+
f"{case_state_instruction}"
|
|
299
|
+
f"{active_user_observe_instruction}"
|
|
300
|
+
f"{access_packet}"
|
|
301
|
+
"Benchmark task instruction follows.\n\n"
|
|
302
|
+
"----- TERMINAL-BENCH TASK -----\n"
|
|
303
|
+
f"{task_instruction}"
|
|
304
|
+
)
|
|
305
|
+
|
|
306
|
+
|
|
307
|
+
def _task_hash(task_instruction: str) -> str:
|
|
308
|
+
return hashlib.sha256(task_instruction.encode("utf-8")).hexdigest()[:16]
|
|
309
|
+
|
|
310
|
+
|
|
311
|
+
def _merge_metadata(context: AgentContext, payload: dict[str, Any]) -> None:
|
|
312
|
+
metadata = dict(context.metadata or {})
|
|
313
|
+
loopx = dict(metadata.get("loopx") or {})
|
|
314
|
+
loopx.update(payload)
|
|
315
|
+
metadata["loopx"] = loopx
|
|
316
|
+
context.metadata = metadata
|
|
317
|
+
|
|
318
|
+
|
|
319
|
+
def _coerce_int(value: Any) -> int | None:
|
|
320
|
+
if isinstance(value, bool):
|
|
321
|
+
return None
|
|
322
|
+
if isinstance(value, int):
|
|
323
|
+
return value
|
|
324
|
+
if isinstance(value, float) and value.is_integer():
|
|
325
|
+
return int(value)
|
|
326
|
+
return None
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def _coerce_positive_timeout_sec(value: Any, *, default: int) -> int:
|
|
330
|
+
if value in (None, ""):
|
|
331
|
+
return default
|
|
332
|
+
parsed = _coerce_int(value)
|
|
333
|
+
if parsed is None and isinstance(value, str):
|
|
334
|
+
text = value.strip()
|
|
335
|
+
try:
|
|
336
|
+
parsed_float = float(text)
|
|
337
|
+
except ValueError:
|
|
338
|
+
parsed_float = -1.0
|
|
339
|
+
if parsed_float.is_integer():
|
|
340
|
+
parsed = int(parsed_float)
|
|
341
|
+
if parsed is None or parsed <= 0:
|
|
342
|
+
raise ValueError(
|
|
343
|
+
"loopx_codex_preflight_timeout_sec must be a positive integer"
|
|
344
|
+
)
|
|
345
|
+
return parsed
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
def _compact_trace_event_text(value: Any) -> str:
|
|
349
|
+
return str(value or "").strip().lower().replace("-", "_")
|
|
350
|
+
|
|
351
|
+
|
|
352
|
+
def extract_loopx_interaction_counters_from_trace(
|
|
353
|
+
counter_trace: list[dict[str, Any]] | None,
|
|
354
|
+
*,
|
|
355
|
+
prompt_policy_injected: bool,
|
|
356
|
+
harness_skill_or_packet_injected: bool,
|
|
357
|
+
case_result_writeback: str = "not_observed_custom_agent_metadata",
|
|
358
|
+
no_trace_counter_trust_level: str = "runtime_metadata_no_trace_observed",
|
|
359
|
+
) -> dict[str, Any]:
|
|
360
|
+
"""Count compact public interaction trace rows into benchmark counters."""
|
|
361
|
+
|
|
362
|
+
runtime_goal_calls = {
|
|
363
|
+
"create_goal": 0,
|
|
364
|
+
"update_goal": 0,
|
|
365
|
+
}
|
|
366
|
+
loopx_cli_calls = {
|
|
367
|
+
command: 0 for command in TERMINAL_BENCH_LOOPX_COUNTER_TRACE_COMMANDS
|
|
368
|
+
}
|
|
369
|
+
state_reads = 0
|
|
370
|
+
state_writes = 0
|
|
371
|
+
writeback = case_result_writeback
|
|
372
|
+
trace_rows = counter_trace or []
|
|
373
|
+
append_attempted = False
|
|
374
|
+
append_dry_run_ok = False
|
|
375
|
+
append_execute_ok = False
|
|
376
|
+
append_schema_rejected = False
|
|
377
|
+
|
|
378
|
+
for event in trace_rows:
|
|
379
|
+
if not isinstance(event, dict):
|
|
380
|
+
continue
|
|
381
|
+
kind = _compact_trace_event_text(
|
|
382
|
+
event.get("kind") or event.get("type") or event.get("event")
|
|
383
|
+
)
|
|
384
|
+
if not kind and event.get("command"):
|
|
385
|
+
kind = "loopx_cli_call"
|
|
386
|
+
if not kind and event.get("call"):
|
|
387
|
+
kind = "loopx_cli_call"
|
|
388
|
+
if kind == "codex_runtime_goal_tool_call":
|
|
389
|
+
tool_name = _compact_trace_event_text(event.get("name") or event.get("tool"))
|
|
390
|
+
if tool_name in runtime_goal_calls:
|
|
391
|
+
runtime_goal_calls[tool_name] += 1
|
|
392
|
+
continue
|
|
393
|
+
if kind == "loopx_cli_call":
|
|
394
|
+
command = _compact_trace_event_text(event.get("command") or event.get("call"))
|
|
395
|
+
if command in loopx_cli_calls:
|
|
396
|
+
loopx_cli_calls[command] += 1
|
|
397
|
+
if command == TERMINAL_BENCH_LOOPX_ACTIVE_USER_OBSERVE_COMMAND:
|
|
398
|
+
state_reads += 1
|
|
399
|
+
if command == "append_benchmark_run":
|
|
400
|
+
append_attempted = True
|
|
401
|
+
append_schema_rejected = append_schema_rejected or (
|
|
402
|
+
_compact_trace_event_text(event.get("error_kind"))
|
|
403
|
+
in {"schema", "schema_rejected"}
|
|
404
|
+
)
|
|
405
|
+
if event.get("ok") is True and event.get("dry_run") is True:
|
|
406
|
+
append_dry_run_ok = True
|
|
407
|
+
elif event.get("ok") is True:
|
|
408
|
+
append_execute_ok = True
|
|
409
|
+
continue
|
|
410
|
+
if kind == "loopx_state_read":
|
|
411
|
+
state_reads += 1
|
|
412
|
+
continue
|
|
413
|
+
if kind == "loopx_state_write":
|
|
414
|
+
state_writes += 1
|
|
415
|
+
continue
|
|
416
|
+
if kind == "case_result_writeback":
|
|
417
|
+
candidate = _compact_trace_event_text(event.get("target"))
|
|
418
|
+
if candidate:
|
|
419
|
+
writeback = candidate
|
|
420
|
+
|
|
421
|
+
if writeback == case_result_writeback:
|
|
422
|
+
if append_execute_ok:
|
|
423
|
+
writeback = "worker_bridge_append_benchmark_run_execute"
|
|
424
|
+
state_writes += 1
|
|
425
|
+
elif append_dry_run_ok:
|
|
426
|
+
writeback = "worker_bridge_append_benchmark_run_dry_run"
|
|
427
|
+
elif append_schema_rejected:
|
|
428
|
+
writeback = "worker_bridge_append_benchmark_run_schema_rejected"
|
|
429
|
+
elif append_attempted:
|
|
430
|
+
writeback = "worker_bridge_append_benchmark_run_failed"
|
|
431
|
+
|
|
432
|
+
return build_terminal_bench_loopx_interaction_counters(
|
|
433
|
+
prompt_policy_injected=prompt_policy_injected,
|
|
434
|
+
harness_skill_or_packet_injected=harness_skill_or_packet_injected,
|
|
435
|
+
codex_runtime_goal_tool_calls=runtime_goal_calls,
|
|
436
|
+
loopx_cli_calls=loopx_cli_calls,
|
|
437
|
+
loopx_state_reads=state_reads,
|
|
438
|
+
loopx_state_writes=state_writes,
|
|
439
|
+
case_result_writeback=writeback,
|
|
440
|
+
counter_trust_level=(
|
|
441
|
+
"compact_trace_audited" if trace_rows else no_trace_counter_trust_level
|
|
442
|
+
),
|
|
443
|
+
)
|
|
444
|
+
|
|
445
|
+
|
|
446
|
+
def load_loopx_counter_trace_file(path: str | Path | None) -> list[dict[str, Any]]:
|
|
447
|
+
"""Load compact LoopX counter trace JSONL rows from a private path."""
|
|
448
|
+
|
|
449
|
+
if not path:
|
|
450
|
+
return []
|
|
451
|
+
trace_path = Path(path)
|
|
452
|
+
try:
|
|
453
|
+
lines = trace_path.read_text(encoding="utf-8").splitlines()
|
|
454
|
+
except OSError:
|
|
455
|
+
return []
|
|
456
|
+
|
|
457
|
+
rows: list[dict[str, Any]] = []
|
|
458
|
+
allowed_keys = {
|
|
459
|
+
"kind",
|
|
460
|
+
"type",
|
|
461
|
+
"event",
|
|
462
|
+
"command",
|
|
463
|
+
"call",
|
|
464
|
+
"ok",
|
|
465
|
+
"dry_run",
|
|
466
|
+
"error_kind",
|
|
467
|
+
"surface",
|
|
468
|
+
"action",
|
|
469
|
+
"target",
|
|
470
|
+
"name",
|
|
471
|
+
"tool",
|
|
472
|
+
"goal_id",
|
|
473
|
+
"mode",
|
|
474
|
+
"loopx_mode",
|
|
475
|
+
"classification",
|
|
476
|
+
"trace_schema_version",
|
|
477
|
+
"benchmark_run_schema_version",
|
|
478
|
+
}
|
|
479
|
+
for line in lines[:200]:
|
|
480
|
+
stripped = line.strip()
|
|
481
|
+
if not stripped:
|
|
482
|
+
continue
|
|
483
|
+
try:
|
|
484
|
+
payload = json.loads(stripped)
|
|
485
|
+
except json.JSONDecodeError:
|
|
486
|
+
continue
|
|
487
|
+
if not isinstance(payload, dict):
|
|
488
|
+
continue
|
|
489
|
+
compact: dict[str, str | int | float | bool] = {}
|
|
490
|
+
for key, value in payload.items():
|
|
491
|
+
if key not in allowed_keys or not isinstance(value, (str, int, float, bool)):
|
|
492
|
+
continue
|
|
493
|
+
compact[key] = value if isinstance(value, (int, float, bool)) else value[:120]
|
|
494
|
+
if compact:
|
|
495
|
+
rows.append(compact)
|
|
496
|
+
return rows
|
|
497
|
+
|
|
498
|
+
|
|
499
|
+
def extract_codex_session_usage(session_dir: Path) -> dict[str, int] | None:
|
|
500
|
+
"""Extract the last compact token-count total from Codex session JSONL."""
|
|
501
|
+
|
|
502
|
+
latest_usage: dict[str, int] | None = None
|
|
503
|
+
for session_file in sorted(session_dir.glob("*.jsonl")):
|
|
504
|
+
try:
|
|
505
|
+
lines = session_file.read_text(encoding="utf-8").splitlines()
|
|
506
|
+
except OSError:
|
|
507
|
+
continue
|
|
508
|
+
|
|
509
|
+
for line in lines:
|
|
510
|
+
try:
|
|
511
|
+
event = json.loads(line)
|
|
512
|
+
except json.JSONDecodeError:
|
|
513
|
+
continue
|
|
514
|
+
|
|
515
|
+
if event.get("type") != "event_msg":
|
|
516
|
+
continue
|
|
517
|
+
payload = event.get("payload")
|
|
518
|
+
if not isinstance(payload, dict) or payload.get("type") != "token_count":
|
|
519
|
+
continue
|
|
520
|
+
info = payload.get("info")
|
|
521
|
+
if not isinstance(info, dict):
|
|
522
|
+
continue
|
|
523
|
+
total_usage = info.get("total_token_usage")
|
|
524
|
+
if not isinstance(total_usage, dict):
|
|
525
|
+
continue
|
|
526
|
+
|
|
527
|
+
input_tokens = _coerce_int(total_usage.get("input_tokens"))
|
|
528
|
+
output_tokens = _coerce_int(total_usage.get("output_tokens"))
|
|
529
|
+
if input_tokens is None or output_tokens is None:
|
|
530
|
+
continue
|
|
531
|
+
|
|
532
|
+
usage = {
|
|
533
|
+
"input_tokens": input_tokens,
|
|
534
|
+
"output_tokens": output_tokens,
|
|
535
|
+
}
|
|
536
|
+
cache_tokens = _coerce_int(total_usage.get("cached_input_tokens"))
|
|
537
|
+
if cache_tokens is not None:
|
|
538
|
+
usage["cache_tokens"] = cache_tokens
|
|
539
|
+
reasoning_output_tokens = _coerce_int(
|
|
540
|
+
total_usage.get("reasoning_output_tokens")
|
|
541
|
+
)
|
|
542
|
+
if reasoning_output_tokens is not None:
|
|
543
|
+
usage["reasoning_output_tokens"] = reasoning_output_tokens
|
|
544
|
+
total_tokens = _coerce_int(total_usage.get("total_tokens"))
|
|
545
|
+
if total_tokens is not None:
|
|
546
|
+
usage["total_tokens"] = total_tokens
|
|
547
|
+
latest_usage = usage
|
|
548
|
+
|
|
549
|
+
return latest_usage
|
|
550
|
+
|
|
551
|
+
|
|
552
|
+
def _context_has_usage(context: AgentContext) -> bool:
|
|
553
|
+
return any(
|
|
554
|
+
value is not None
|
|
555
|
+
for value in (
|
|
556
|
+
context.n_input_tokens,
|
|
557
|
+
context.n_cache_tokens,
|
|
558
|
+
context.n_output_tokens,
|
|
559
|
+
context.cost_usd,
|
|
560
|
+
)
|
|
561
|
+
)
|
|
562
|
+
|
|
563
|
+
|
|
564
|
+
class GoalHarnessManagedCodex(Codex):
|
|
565
|
+
"""Harbor custom agent that runs Codex with a LoopX policy envelope."""
|
|
566
|
+
|
|
567
|
+
@staticmethod
|
|
568
|
+
def name() -> str:
|
|
569
|
+
return "loopx-managed-codex"
|
|
570
|
+
|
|
571
|
+
def __init__(
|
|
572
|
+
self,
|
|
573
|
+
*args: Any,
|
|
574
|
+
loopx_policy_version: str = LOOPX_MANAGED_CODEX_POLICY_VERSION,
|
|
575
|
+
loopx_behavior_spec_id: str = LOOPX_MANAGED_CODEX_BEHAVIOR_SPEC_ID,
|
|
576
|
+
loopx_ablation_mode: str = "loopx_managed",
|
|
577
|
+
loopx_mode: str = LOOPX_MANAGED_CODEX_MODE,
|
|
578
|
+
loopx_codex_install_strategy: str = (
|
|
579
|
+
TERMINAL_BENCH_CODEX_INSTALL_STRATEGY_RUNTIME_INSTALL_IF_MISSING
|
|
580
|
+
),
|
|
581
|
+
loopx_codex_preflight_timeout_sec: int | str | None = (
|
|
582
|
+
DEFAULT_CODEX_PREFLIGHT_TIMEOUT_SEC
|
|
583
|
+
),
|
|
584
|
+
loopx_worker_codex_materialization_strategy: str = "",
|
|
585
|
+
loopx_worker_materialization_probe_only: bool = False,
|
|
586
|
+
loopx_goal_id: str = "<goal-id>",
|
|
587
|
+
loopx_access_packet_mode: str = (
|
|
588
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_FULL
|
|
589
|
+
),
|
|
590
|
+
loopx_trace_publicness: str = "private_raw_trace_compact_public_summary",
|
|
591
|
+
loopx_counter_trace: list[dict[str, Any]] | None = None,
|
|
592
|
+
loopx_cli_bridge_enabled: bool = False,
|
|
593
|
+
loopx_command_prefix: str = DEFAULT_LOOPX_WORKER_COMMAND_PREFIX,
|
|
594
|
+
loopx_runtime_preflight_command: str = (
|
|
595
|
+
DEFAULT_LOOPX_WORKER_RUNTIME_PREFLIGHT_COMMAND
|
|
596
|
+
),
|
|
597
|
+
loopx_registry_arg: str = DEFAULT_LOOPX_WORKER_REGISTRY_ARG,
|
|
598
|
+
loopx_runtime_root_arg: str = LOOPX_RUNTIME_ROOT_PLACEHOLDER,
|
|
599
|
+
loopx_scan_path: str = DEFAULT_LOOPX_WORKER_SCAN_PATH,
|
|
600
|
+
loopx_benchmark_run_json: str = DEFAULT_WORKER_BRIDGE_BENCHMARK_RUN_JSON,
|
|
601
|
+
loopx_benchmark_run_schema_version: str = "benchmark_run_v0",
|
|
602
|
+
loopx_benchmark_run_writeback_contract: str = (
|
|
603
|
+
WORKER_BRIDGE_BENCHMARK_RUN_WRITEBACK_CONTRACT_VERSION
|
|
604
|
+
),
|
|
605
|
+
loopx_counter_trace_json: str = DEFAULT_WORKER_BRIDGE_COUNTER_TRACE_JSON,
|
|
606
|
+
loopx_classification: str = "<classification>",
|
|
607
|
+
loopx_append_execute_enabled: bool = False,
|
|
608
|
+
loopx_active_user_intervention_enabled: bool = False,
|
|
609
|
+
loopx_active_user_feed_jsonl: str = DEFAULT_WORKER_BRIDGE_ACTIVE_USER_FEED_JSONL,
|
|
610
|
+
loopx_active_user_observation_json: str = DEFAULT_WORKER_BRIDGE_ACTIVE_USER_OBSERVATION_JSON,
|
|
611
|
+
loopx_active_user_observe_command: str = "<active-user-observe-command>",
|
|
612
|
+
loopx_active_user_channel_surface: str = ACTIVE_USER_INTERVENTION_CHANNEL_SURFACE,
|
|
613
|
+
**kwargs: Any,
|
|
614
|
+
) -> None:
|
|
615
|
+
self.loopx_policy_version = loopx_policy_version
|
|
616
|
+
self.loopx_behavior_spec_id = loopx_behavior_spec_id
|
|
617
|
+
self.loopx_ablation_mode = loopx_ablation_mode
|
|
618
|
+
self.loopx_mode = loopx_mode
|
|
619
|
+
if loopx_codex_install_strategy not in TERMINAL_BENCH_CODEX_INSTALL_STRATEGIES:
|
|
620
|
+
raise ValueError(
|
|
621
|
+
"loopx_codex_install_strategy must be one of: "
|
|
622
|
+
+ ", ".join(TERMINAL_BENCH_CODEX_INSTALL_STRATEGIES)
|
|
623
|
+
)
|
|
624
|
+
self.loopx_codex_install_strategy = loopx_codex_install_strategy
|
|
625
|
+
self.loopx_codex_preflight_timeout_sec = _coerce_positive_timeout_sec(
|
|
626
|
+
loopx_codex_preflight_timeout_sec,
|
|
627
|
+
default=DEFAULT_CODEX_PREFLIGHT_TIMEOUT_SEC,
|
|
628
|
+
)
|
|
629
|
+
if (
|
|
630
|
+
loopx_worker_codex_materialization_strategy
|
|
631
|
+
and loopx_worker_codex_materialization_strategy
|
|
632
|
+
not in TERMINAL_BENCH_WORKER_CODEX_MATERIALIZATION_STRATEGIES
|
|
633
|
+
):
|
|
634
|
+
raise ValueError(
|
|
635
|
+
"loopx_worker_codex_materialization_strategy must be one of: "
|
|
636
|
+
+ ", ".join(TERMINAL_BENCH_WORKER_CODEX_MATERIALIZATION_STRATEGIES)
|
|
637
|
+
)
|
|
638
|
+
self.loopx_worker_codex_materialization_strategy = (
|
|
639
|
+
loopx_worker_codex_materialization_strategy
|
|
640
|
+
)
|
|
641
|
+
self.loopx_worker_materialization_probe_only = bool(
|
|
642
|
+
loopx_worker_materialization_probe_only
|
|
643
|
+
)
|
|
644
|
+
self.loopx_goal_id = loopx_goal_id
|
|
645
|
+
if loopx_access_packet_mode not in TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODES:
|
|
646
|
+
raise ValueError(
|
|
647
|
+
"loopx_access_packet_mode must be one of: "
|
|
648
|
+
+ ", ".join(TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODES)
|
|
649
|
+
)
|
|
650
|
+
self.loopx_access_packet_mode = loopx_access_packet_mode
|
|
651
|
+
self.loopx_trace_publicness = loopx_trace_publicness
|
|
652
|
+
self.loopx_counter_trace = loopx_counter_trace or []
|
|
653
|
+
self.loopx_cli_bridge_enabled = bool(loopx_cli_bridge_enabled)
|
|
654
|
+
self.loopx_command_prefix = loopx_command_prefix
|
|
655
|
+
self.loopx_runtime_preflight_command = loopx_runtime_preflight_command
|
|
656
|
+
self.loopx_registry_arg = loopx_registry_arg
|
|
657
|
+
self.loopx_runtime_root_arg = loopx_runtime_root_arg
|
|
658
|
+
self.loopx_scan_path = loopx_scan_path
|
|
659
|
+
self.loopx_benchmark_run_json = loopx_benchmark_run_json
|
|
660
|
+
self.loopx_benchmark_run_schema_version = (
|
|
661
|
+
loopx_benchmark_run_schema_version
|
|
662
|
+
)
|
|
663
|
+
self.loopx_benchmark_run_writeback_contract = (
|
|
664
|
+
loopx_benchmark_run_writeback_contract
|
|
665
|
+
)
|
|
666
|
+
self.loopx_counter_trace_json = loopx_counter_trace_json
|
|
667
|
+
self.loopx_classification = loopx_classification
|
|
668
|
+
self.loopx_append_execute_enabled = bool(
|
|
669
|
+
loopx_append_execute_enabled
|
|
670
|
+
)
|
|
671
|
+
self.loopx_active_user_intervention_enabled = bool(
|
|
672
|
+
loopx_active_user_intervention_enabled
|
|
673
|
+
)
|
|
674
|
+
self.loopx_active_user_feed_jsonl = loopx_active_user_feed_jsonl
|
|
675
|
+
self.loopx_active_user_observation_json = (
|
|
676
|
+
loopx_active_user_observation_json
|
|
677
|
+
)
|
|
678
|
+
self.loopx_active_user_observe_command = (
|
|
679
|
+
loopx_active_user_observe_command
|
|
680
|
+
)
|
|
681
|
+
self.loopx_active_user_channel_surface = (
|
|
682
|
+
loopx_active_user_channel_surface
|
|
683
|
+
)
|
|
684
|
+
self._loopx_context_metadata: dict[str, Any] = {}
|
|
685
|
+
super().__init__(*args, **kwargs)
|
|
686
|
+
|
|
687
|
+
def _write_loopx_setup_diagnostic(
|
|
688
|
+
self,
|
|
689
|
+
*,
|
|
690
|
+
interrupted: bool,
|
|
691
|
+
interrupt_reason: str,
|
|
692
|
+
checkpoint_kind: str,
|
|
693
|
+
codex_path_observed: bool | None = None,
|
|
694
|
+
) -> tuple[dict[str, Any], bool, str]:
|
|
695
|
+
"""Write public-safe setup diagnostics for every Terminal-Bench arm."""
|
|
696
|
+
|
|
697
|
+
blocker = str(interrupt_reason or "").strip() or "worker_setup_unknown"
|
|
698
|
+
payload: dict[str, Any] = {
|
|
699
|
+
"schema_version": TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_SCHEMA,
|
|
700
|
+
"checkpoint_kind": checkpoint_kind,
|
|
701
|
+
"interrupted": bool(interrupted),
|
|
702
|
+
"first_blocker": blocker,
|
|
703
|
+
"pre_worker_startup_blocker": blocker if interrupted else "none",
|
|
704
|
+
"loopx_mode": self.loopx_mode,
|
|
705
|
+
"loopx_ablation_mode": self.loopx_ablation_mode,
|
|
706
|
+
"loopx_access_packet_mode": self.loopx_access_packet_mode,
|
|
707
|
+
"codex_install_strategy": self.loopx_codex_install_strategy,
|
|
708
|
+
"worker_codex_materialization_strategy": (
|
|
709
|
+
self.loopx_worker_codex_materialization_strategy
|
|
710
|
+
),
|
|
711
|
+
"worker_codex_materialization_strategy_declared": bool(
|
|
712
|
+
self.loopx_worker_codex_materialization_strategy
|
|
713
|
+
),
|
|
714
|
+
"codex_preflight_timeout_sec": (
|
|
715
|
+
self.loopx_codex_preflight_timeout_sec
|
|
716
|
+
),
|
|
717
|
+
"codex_path_observed": codex_path_observed,
|
|
718
|
+
"raw_paths_recorded": False,
|
|
719
|
+
"raw_logs_read": False,
|
|
720
|
+
"raw_task_text_read": False,
|
|
721
|
+
"trajectory_read": False,
|
|
722
|
+
"credential_values_recorded": False,
|
|
723
|
+
"command_output_recorded": False,
|
|
724
|
+
"case_goal_state_init_required": self._benchmark_case_active_state_required(),
|
|
725
|
+
"case_goal_state_path": (
|
|
726
|
+
TERMINAL_BENCH_CASE_STATE_PATH
|
|
727
|
+
if self._benchmark_case_active_state_required()
|
|
728
|
+
else None
|
|
729
|
+
),
|
|
730
|
+
"case_goal_state_schema_version": (
|
|
731
|
+
BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION
|
|
732
|
+
if self._benchmark_case_active_state_required()
|
|
733
|
+
else None
|
|
734
|
+
),
|
|
735
|
+
"case_goal_state_initialized_before_agent": False,
|
|
736
|
+
"case_goal_state_init_status": "not_started"
|
|
737
|
+
if self._benchmark_case_active_state_required()
|
|
738
|
+
else "not_applicable",
|
|
739
|
+
}
|
|
740
|
+
try:
|
|
741
|
+
target = Path(self.logs_dir) / TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_FILE
|
|
742
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
743
|
+
target.write_text(
|
|
744
|
+
json.dumps(payload, indent=2, sort_keys=True) + "\n",
|
|
745
|
+
encoding="utf-8",
|
|
746
|
+
)
|
|
747
|
+
return payload, True, "worker_setup_diagnostic_written"
|
|
748
|
+
except Exception:
|
|
749
|
+
logger = getattr(self, "logger", None)
|
|
750
|
+
if logger is not None:
|
|
751
|
+
logger.exception("LoopX setup diagnostic write failed")
|
|
752
|
+
return payload, False, "worker_setup_diagnostic_write_failed"
|
|
753
|
+
|
|
754
|
+
def _best_effort_loopx_setup_diagnostic(
|
|
755
|
+
self,
|
|
756
|
+
*,
|
|
757
|
+
interrupted: bool,
|
|
758
|
+
interrupt_reason: str,
|
|
759
|
+
checkpoint_kind: str,
|
|
760
|
+
codex_path_observed: bool | None = None,
|
|
761
|
+
) -> tuple[dict[str, Any] | None, bool, str]:
|
|
762
|
+
try:
|
|
763
|
+
return self._write_loopx_setup_diagnostic(
|
|
764
|
+
interrupted=interrupted,
|
|
765
|
+
interrupt_reason=interrupt_reason,
|
|
766
|
+
checkpoint_kind=checkpoint_kind,
|
|
767
|
+
codex_path_observed=codex_path_observed,
|
|
768
|
+
)
|
|
769
|
+
except Exception:
|
|
770
|
+
return None, False, "worker_setup_diagnostic_write_failed"
|
|
771
|
+
|
|
772
|
+
def _load_loopx_setup_diagnostic(self) -> dict[str, Any]:
|
|
773
|
+
"""Load the compact setup diagnostic written during install/preflight."""
|
|
774
|
+
|
|
775
|
+
try:
|
|
776
|
+
target = Path(self.logs_dir) / TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_FILE
|
|
777
|
+
if not target.exists():
|
|
778
|
+
return {}
|
|
779
|
+
loaded = json.loads(target.read_text(encoding="utf-8"))
|
|
780
|
+
except Exception:
|
|
781
|
+
return {}
|
|
782
|
+
return loaded if isinstance(loaded, dict) else {}
|
|
783
|
+
|
|
784
|
+
def _read_loopx_setup_stage_marker(self) -> str:
|
|
785
|
+
"""Read a public-safe setup stage marker written before risky install steps."""
|
|
786
|
+
|
|
787
|
+
try:
|
|
788
|
+
target = Path(self.logs_dir) / "loopx-worker-setup-stage.txt"
|
|
789
|
+
if not target.exists():
|
|
790
|
+
return ""
|
|
791
|
+
value = target.read_text(encoding="utf-8").strip()
|
|
792
|
+
except Exception:
|
|
793
|
+
return ""
|
|
794
|
+
if not re.fullmatch(r"[a-z0-9_]{1,96}", value):
|
|
795
|
+
return ""
|
|
796
|
+
return value
|
|
797
|
+
|
|
798
|
+
def _write_loopx_worker_materialization_probe_result(
|
|
799
|
+
self,
|
|
800
|
+
*,
|
|
801
|
+
interface_surface: str,
|
|
802
|
+
runtime_preflight_status: str,
|
|
803
|
+
interrupted: bool = False,
|
|
804
|
+
interrupt_reason: str = "",
|
|
805
|
+
) -> tuple[dict[str, Any] | None, bool, str]:
|
|
806
|
+
"""Write a compact proof that the worker materialized Codex, not task success."""
|
|
807
|
+
|
|
808
|
+
if not self.loopx_benchmark_run_json:
|
|
809
|
+
return None, False, "worker_materialization_probe_path_missing"
|
|
810
|
+
|
|
811
|
+
setup = self._load_loopx_setup_diagnostic()
|
|
812
|
+
setup_schema_ok = (
|
|
813
|
+
setup.get("schema_version") == TERMINAL_BENCH_WORKER_SETUP_DIAGNOSTIC_SCHEMA
|
|
814
|
+
)
|
|
815
|
+
setup_file_count = 1 if setup else 0
|
|
816
|
+
setup_schema_ok_count = 1 if setup_schema_ok else 0
|
|
817
|
+
setup_blocker = str(
|
|
818
|
+
setup.get("pre_worker_startup_blocker")
|
|
819
|
+
or setup.get("first_blocker")
|
|
820
|
+
or ""
|
|
821
|
+
).strip()
|
|
822
|
+
if interrupt_reason:
|
|
823
|
+
setup_blocker = interrupt_reason
|
|
824
|
+
setup_ok_blockers = {
|
|
825
|
+
"",
|
|
826
|
+
"none",
|
|
827
|
+
"codex_runtime_install_or_preflight_ok",
|
|
828
|
+
"codex_require_existing_preflight_ok",
|
|
829
|
+
}
|
|
830
|
+
setup_ok = (
|
|
831
|
+
setup_schema_ok
|
|
832
|
+
and setup.get("interrupted") is False
|
|
833
|
+
and setup_blocker in setup_ok_blockers
|
|
834
|
+
and not interrupted
|
|
835
|
+
)
|
|
836
|
+
materialization_status = (
|
|
837
|
+
"worker_codex_materialization_verified"
|
|
838
|
+
if setup_ok
|
|
839
|
+
else "worker_codex_materialization_blocked"
|
|
840
|
+
)
|
|
841
|
+
materialization_blocker = "none" if setup_ok else setup_blocker or "setup_diagnostic_missing"
|
|
842
|
+
runner_status = (
|
|
843
|
+
"worker_materialization_probe_completed"
|
|
844
|
+
if setup_ok
|
|
845
|
+
else "worker_materialization_probe_blocked"
|
|
846
|
+
)
|
|
847
|
+
official_score_status = "not_run_worker_materialization_probe"
|
|
848
|
+
mode = (
|
|
849
|
+
"codex_goal_mode_baseline_worker_materialization_probe"
|
|
850
|
+
if self._codex_goal_mode_baseline()
|
|
851
|
+
else "hardened_codex_baseline_worker_materialization_probe"
|
|
852
|
+
if self._hardened_codex_baseline()
|
|
853
|
+
else "loopx_worker_materialization_probe"
|
|
854
|
+
)
|
|
855
|
+
claim_boundary = {
|
|
856
|
+
"public_claim_allowed": "worker materialization only",
|
|
857
|
+
"bridge_connectivity_claim_allowed": False,
|
|
858
|
+
"case_success_claim_allowed": False,
|
|
859
|
+
"official_score_claim_allowed": False,
|
|
860
|
+
"leaderboard_claim_allowed": False,
|
|
861
|
+
"forbidden_claims": [
|
|
862
|
+
"case_success",
|
|
863
|
+
"official_reward_complete",
|
|
864
|
+
"leaderboard_ready",
|
|
865
|
+
"uplift_over_baseline",
|
|
866
|
+
"raw_trace_public",
|
|
867
|
+
],
|
|
868
|
+
}
|
|
869
|
+
payload: dict[str, Any] = {
|
|
870
|
+
"ok": setup_ok,
|
|
871
|
+
"schema_version": self.loopx_benchmark_run_schema_version
|
|
872
|
+
or "benchmark_run_v0",
|
|
873
|
+
"source_runner": "terminal_bench_worker_materialization_probe",
|
|
874
|
+
"benchmark_id": "terminal-bench-worker-materialization@v0",
|
|
875
|
+
"job_name": "terminal_bench_worker_materialization_probe",
|
|
876
|
+
"mode": mode,
|
|
877
|
+
"worker_mode": self.loopx_mode,
|
|
878
|
+
"real_run": False,
|
|
879
|
+
"worker_materialization_real_probe": True,
|
|
880
|
+
"submit_eligible": False,
|
|
881
|
+
"leaderboard_evidence": False,
|
|
882
|
+
"trace_publicness": "compact_setup_diagnostic_only_no_raw_trace",
|
|
883
|
+
"task_prompt_changed_by_loopx_policy": False,
|
|
884
|
+
"raw_task_instruction_recorded": False,
|
|
885
|
+
"raw_managed_prompt_recorded": False,
|
|
886
|
+
"raw_interaction_trace_recorded": False,
|
|
887
|
+
"credential_values_recorded": False,
|
|
888
|
+
"auth_files_recorded": False,
|
|
889
|
+
"command_output_recorded": False,
|
|
890
|
+
"official_task_score": {"kind": official_score_status},
|
|
891
|
+
"official_score": None,
|
|
892
|
+
"first_blocker": "none" if setup_ok else materialization_blocker,
|
|
893
|
+
"repeat_blocked_by": "none" if setup_ok else materialization_blocker,
|
|
894
|
+
"progress": {
|
|
895
|
+
"n_total_trials": 0,
|
|
896
|
+
"n_completed_trials": 0,
|
|
897
|
+
"n_errored_trials": 0 if setup_ok else 1,
|
|
898
|
+
"n_running_trials": 0,
|
|
899
|
+
"n_pending_trials": 0,
|
|
900
|
+
"n_cancelled_trials": 0,
|
|
901
|
+
"n_retries": 0,
|
|
902
|
+
},
|
|
903
|
+
"metrics": {
|
|
904
|
+
"input_tokens": 0,
|
|
905
|
+
"cache_tokens": 0,
|
|
906
|
+
"output_tokens": 0,
|
|
907
|
+
"cost_usd": 0,
|
|
908
|
+
},
|
|
909
|
+
"worker_setup_diagnostic_file_count": setup_file_count,
|
|
910
|
+
"worker_setup_diagnostic_schema_ok_count": setup_schema_ok_count,
|
|
911
|
+
"worker_setup_diagnostic_blockers": []
|
|
912
|
+
if setup_ok
|
|
913
|
+
else [materialization_blocker],
|
|
914
|
+
"worker_bridge_outcome": {
|
|
915
|
+
"schema_version": "terminal_bench_worker_materialization_probe_outcome_v0",
|
|
916
|
+
"bridge_surface": interface_surface,
|
|
917
|
+
"runner_return_status": runner_status,
|
|
918
|
+
"official_score_status": official_score_status,
|
|
919
|
+
"trace_publicness": "compact_setup_diagnostic_only_no_raw_trace",
|
|
920
|
+
"worker_bridge_verified": False,
|
|
921
|
+
"counter_trace_present": False,
|
|
922
|
+
"runner_return_completed": True,
|
|
923
|
+
"official_score_completed": False,
|
|
924
|
+
"side_effect_audit_passed": True,
|
|
925
|
+
"raw_paths_recorded": False,
|
|
926
|
+
"raw_trace_recorded": False,
|
|
927
|
+
"credential_values_recorded": False,
|
|
928
|
+
"worker_bridge_materialization_status": materialization_status,
|
|
929
|
+
"worker_bridge_materialization_blocker": materialization_blocker,
|
|
930
|
+
"worker_bridge_failure_attribution": (
|
|
931
|
+
"none" if setup_ok else materialization_blocker
|
|
932
|
+
),
|
|
933
|
+
"worker_setup_diagnostic_file_count": setup_file_count,
|
|
934
|
+
"worker_setup_diagnostic_schema_ok_count": setup_schema_ok_count,
|
|
935
|
+
"worker_startup_blocker_count": 0 if setup_ok else 1,
|
|
936
|
+
"next_action": (
|
|
937
|
+
"run the paired baseline or treatment slice"
|
|
938
|
+
if setup_ok
|
|
939
|
+
else "repair worker Codex materialization before repeat"
|
|
940
|
+
),
|
|
941
|
+
},
|
|
942
|
+
"claim_boundary": claim_boundary,
|
|
943
|
+
"validation": {
|
|
944
|
+
"validation_scope": "worker_codex_materialization_probe",
|
|
945
|
+
"worker_bridge_materialized_when_required": setup_ok,
|
|
946
|
+
"worker_bridge_repeat_ready": setup_ok,
|
|
947
|
+
"runner_return_completed_or_blocker_recorded": True,
|
|
948
|
+
"worker_startup_blocker_recorded": True,
|
|
949
|
+
"no_model_task_solution_invoked": True,
|
|
950
|
+
"no_leaderboard_upload_requested": True,
|
|
951
|
+
"paths_redacted": True,
|
|
952
|
+
"raw_trace_excluded": True,
|
|
953
|
+
"side_effect_audit_passed": True,
|
|
954
|
+
},
|
|
955
|
+
"case_semantics_changed_by_harness": False,
|
|
956
|
+
"loopx_inside_case": False,
|
|
957
|
+
"official_score_comparable_to_native_codex": False,
|
|
958
|
+
"official_score_comparable_to_loopx_treatment": False,
|
|
959
|
+
"model_plus_harness_pair": False,
|
|
960
|
+
"control_plane_score_applicable": False,
|
|
961
|
+
"startup_surface_calibration": True,
|
|
962
|
+
"codex_goal_mode_baseline": self._codex_goal_mode_baseline(),
|
|
963
|
+
"hardened_install_baseline": self._hardened_codex_baseline(),
|
|
964
|
+
"runtime_preflight_status": runtime_preflight_status,
|
|
965
|
+
"stop_conditions": [
|
|
966
|
+
"do_not_run_task_solver_in_materialization_probe",
|
|
967
|
+
"do_not_upload_or_submit_leaderboard",
|
|
968
|
+
"do_not_claim_case_success_from_worker_materialization",
|
|
969
|
+
"do_not_record_raw_trace_or_paths",
|
|
970
|
+
],
|
|
971
|
+
"trials": [],
|
|
972
|
+
}
|
|
973
|
+
written = write_worker_bridge_benchmark_run_file(
|
|
974
|
+
self._host_worker_bridge_artifact_path(
|
|
975
|
+
self.loopx_benchmark_run_json
|
|
976
|
+
),
|
|
977
|
+
payload,
|
|
978
|
+
)
|
|
979
|
+
status = (
|
|
980
|
+
"worker_materialization_probe_written"
|
|
981
|
+
if written
|
|
982
|
+
else "worker_materialization_probe_write_failed"
|
|
983
|
+
)
|
|
984
|
+
return payload, written, status
|
|
985
|
+
|
|
986
|
+
async def _require_existing_codex_cli(self, environment: BaseEnvironment) -> str:
|
|
987
|
+
"""Fail fast with a precise setup blocker when Codex is unavailable."""
|
|
988
|
+
|
|
989
|
+
try:
|
|
990
|
+
result = await self.exec_as_agent(
|
|
991
|
+
environment,
|
|
992
|
+
command="set -euo pipefail; command -v codex",
|
|
993
|
+
timeout_sec=self.loopx_codex_preflight_timeout_sec,
|
|
994
|
+
)
|
|
995
|
+
except Exception:
|
|
996
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
997
|
+
interrupted=True,
|
|
998
|
+
interrupt_reason=CODEX_REQUIRE_EXISTING_BLOCKER_NOT_ON_PATH,
|
|
999
|
+
checkpoint_kind="pre_worker_setup_probe",
|
|
1000
|
+
codex_path_observed=False,
|
|
1001
|
+
)
|
|
1002
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
1003
|
+
interrupted=True,
|
|
1004
|
+
interrupt_reason=CODEX_REQUIRE_EXISTING_BLOCKER_NOT_ON_PATH,
|
|
1005
|
+
checkpoint_kind="pre_worker_startup_blocker",
|
|
1006
|
+
)
|
|
1007
|
+
raise
|
|
1008
|
+
|
|
1009
|
+
codex_path = ""
|
|
1010
|
+
stdout = getattr(result, "stdout", "")
|
|
1011
|
+
if isinstance(stdout, str):
|
|
1012
|
+
codex_path = stdout.strip().splitlines()[0] if stdout.strip() else ""
|
|
1013
|
+
|
|
1014
|
+
try:
|
|
1015
|
+
await self.exec_as_agent(
|
|
1016
|
+
environment,
|
|
1017
|
+
command=(
|
|
1018
|
+
"set -euo pipefail; "
|
|
1019
|
+
"codex --version >/dev/null 2>&1; "
|
|
1020
|
+
"codex --version"
|
|
1021
|
+
),
|
|
1022
|
+
timeout_sec=self.loopx_codex_preflight_timeout_sec,
|
|
1023
|
+
)
|
|
1024
|
+
except Exception:
|
|
1025
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
1026
|
+
interrupted=True,
|
|
1027
|
+
interrupt_reason=CODEX_REQUIRE_EXISTING_BLOCKER_VERSION_PROBE_FAILED,
|
|
1028
|
+
checkpoint_kind="pre_worker_setup_probe",
|
|
1029
|
+
codex_path_observed=bool(codex_path),
|
|
1030
|
+
)
|
|
1031
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
1032
|
+
interrupted=True,
|
|
1033
|
+
interrupt_reason=CODEX_REQUIRE_EXISTING_BLOCKER_VERSION_PROBE_FAILED,
|
|
1034
|
+
checkpoint_kind="pre_worker_startup_blocker",
|
|
1035
|
+
)
|
|
1036
|
+
raise
|
|
1037
|
+
|
|
1038
|
+
if codex_path.startswith("/"):
|
|
1039
|
+
try:
|
|
1040
|
+
await self.exec_as_root(
|
|
1041
|
+
environment,
|
|
1042
|
+
command=(
|
|
1043
|
+
"set -euo pipefail; "
|
|
1044
|
+
f"BIN_PATH={shlex.quote(codex_path)}; "
|
|
1045
|
+
'if [ "$BIN_PATH" != "/usr/local/bin/codex" ]; then '
|
|
1046
|
+
'ln -sf "$BIN_PATH" "/usr/local/bin/codex"; '
|
|
1047
|
+
"fi"
|
|
1048
|
+
),
|
|
1049
|
+
timeout_sec=self.loopx_codex_preflight_timeout_sec,
|
|
1050
|
+
)
|
|
1051
|
+
except Exception:
|
|
1052
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
1053
|
+
interrupted=True,
|
|
1054
|
+
interrupt_reason=(
|
|
1055
|
+
CODEX_REQUIRE_EXISTING_BLOCKER_SYMLINK_REPAIR_FAILED
|
|
1056
|
+
),
|
|
1057
|
+
checkpoint_kind="pre_worker_setup_probe",
|
|
1058
|
+
codex_path_observed=True,
|
|
1059
|
+
)
|
|
1060
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
1061
|
+
interrupted=True,
|
|
1062
|
+
interrupt_reason=CODEX_REQUIRE_EXISTING_BLOCKER_SYMLINK_REPAIR_FAILED,
|
|
1063
|
+
checkpoint_kind="pre_worker_startup_blocker",
|
|
1064
|
+
)
|
|
1065
|
+
raise
|
|
1066
|
+
|
|
1067
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
1068
|
+
interrupted=False,
|
|
1069
|
+
interrupt_reason="codex_require_existing_preflight_ok",
|
|
1070
|
+
checkpoint_kind="pre_worker_setup_probe",
|
|
1071
|
+
codex_path_observed=bool(codex_path),
|
|
1072
|
+
)
|
|
1073
|
+
return codex_path
|
|
1074
|
+
|
|
1075
|
+
async def _repair_agent_node_runtime_path(
|
|
1076
|
+
self, environment: BaseEnvironment
|
|
1077
|
+
) -> None:
|
|
1078
|
+
"""Expose root-installed node/npm binaries on the agent-visible PATH."""
|
|
1079
|
+
|
|
1080
|
+
await self.exec_as_root(
|
|
1081
|
+
environment,
|
|
1082
|
+
command=(
|
|
1083
|
+
"set -euo pipefail; "
|
|
1084
|
+
"mkdir -p /usr/local/bin; "
|
|
1085
|
+
"for bin in node npm; do "
|
|
1086
|
+
' BIN_PATH="$(command -v "$bin" 2>/dev/null || true)"; '
|
|
1087
|
+
' if [ -z "$BIN_PATH" ]; then '
|
|
1088
|
+
" for candidate in /usr/local/bin/$bin /usr/bin/$bin /bin/$bin; do "
|
|
1089
|
+
' if [ -x "$candidate" ]; then BIN_PATH="$candidate"; break; fi; '
|
|
1090
|
+
" done; "
|
|
1091
|
+
" fi; "
|
|
1092
|
+
' if [ "$bin" = "node" ] && [ -z "$BIN_PATH" ] && [ -x /usr/bin/nodejs ]; then '
|
|
1093
|
+
" BIN_PATH=/usr/bin/nodejs; "
|
|
1094
|
+
" fi; "
|
|
1095
|
+
' if [ -n "$BIN_PATH" ] && [ "$BIN_PATH" != "/usr/local/bin/$bin" ]; then '
|
|
1096
|
+
' ln -sf "$BIN_PATH" "/usr/local/bin/$bin"; '
|
|
1097
|
+
" fi; "
|
|
1098
|
+
"done; "
|
|
1099
|
+
"printf 'loopx_worker_node_runtime_path_repair_attempted\\n'"
|
|
1100
|
+
),
|
|
1101
|
+
)
|
|
1102
|
+
|
|
1103
|
+
async def install(self, environment: BaseEnvironment) -> None:
|
|
1104
|
+
"""Install Codex with dependencies needed by minimal benchmark images."""
|
|
1105
|
+
|
|
1106
|
+
version = getattr(self, "_version", None)
|
|
1107
|
+
version_spec = f"@{version}" if version else "@latest"
|
|
1108
|
+
if (
|
|
1109
|
+
self.loopx_codex_install_strategy
|
|
1110
|
+
== TERMINAL_BENCH_CODEX_INSTALL_STRATEGY_REQUIRE_EXISTING
|
|
1111
|
+
):
|
|
1112
|
+
await self._require_existing_codex_cli(environment)
|
|
1113
|
+
return
|
|
1114
|
+
setup_stage = "package_manager_preinstall"
|
|
1115
|
+
try:
|
|
1116
|
+
await self.exec_as_root(
|
|
1117
|
+
environment,
|
|
1118
|
+
command=(
|
|
1119
|
+
"(if [ -f /etc/alpine-release ] || "
|
|
1120
|
+
"(command -v ldd >/dev/null 2>&1 && ldd --version 2>&1 | grep -qi musl); then"
|
|
1121
|
+
" apk add --no-cache bash curl nodejs npm ripgrep;"
|
|
1122
|
+
" elif command -v apt-get >/dev/null 2>&1; then"
|
|
1123
|
+
" apt-get update && apt-get install -y "
|
|
1124
|
+
"bash ca-certificates curl git nodejs npm xz-utils tar gzip ripgrep;"
|
|
1125
|
+
" elif command -v dnf >/dev/null 2>&1; then"
|
|
1126
|
+
" dnf install -y bash ca-certificates curl git nodejs npm xz tar gzip ripgrep;"
|
|
1127
|
+
" elif command -v yum >/dev/null 2>&1; then"
|
|
1128
|
+
" yum install -y bash ca-certificates curl git nodejs npm xz tar gzip ripgrep;"
|
|
1129
|
+
" else"
|
|
1130
|
+
' echo "Warning: No known package manager found, assuming Codex install prerequisites are available" >&2;'
|
|
1131
|
+
" fi) || "
|
|
1132
|
+
'echo "Warning: Package-manager prerequisite install failed; continuing with existing worker tools" >&2'
|
|
1133
|
+
),
|
|
1134
|
+
env={"DEBIAN_FRONTEND": "noninteractive"},
|
|
1135
|
+
)
|
|
1136
|
+
setup_stage = "agent_codex_install"
|
|
1137
|
+
agent_env_prefix = (
|
|
1138
|
+
"set -euo pipefail; "
|
|
1139
|
+
'export NPM_CONFIG_PREFIX="${HOME}/.loopx-codex"; '
|
|
1140
|
+
'export NPM_CONFIG_REGISTRY="${NPM_CONFIG_REGISTRY:-https://registry.npmjs.org}"; '
|
|
1141
|
+
'export PATH="${NPM_CONFIG_PREFIX}/bin:${PATH}"; '
|
|
1142
|
+
'if [ -s "${HOME}/.nvm/nvm.sh" ]; then '
|
|
1143
|
+
' export NVM_DIR="${HOME}/.nvm"; . "$NVM_DIR/nvm.sh"; '
|
|
1144
|
+
"fi; "
|
|
1145
|
+
)
|
|
1146
|
+
codex_probe = await self.exec_as_agent(
|
|
1147
|
+
environment,
|
|
1148
|
+
command=(
|
|
1149
|
+
agent_env_prefix
|
|
1150
|
+
+ "if command -v codex >/dev/null 2>&1 && "
|
|
1151
|
+
"codex --version >/dev/null 2>&1; then "
|
|
1152
|
+
" printf 'loopx_codex_usable\\n'; "
|
|
1153
|
+
"else "
|
|
1154
|
+
" printf 'loopx_codex_missing\\n'; "
|
|
1155
|
+
"fi"
|
|
1156
|
+
),
|
|
1157
|
+
)
|
|
1158
|
+
codex_probe_stdout = str(getattr(codex_probe, "stdout", "") or "")
|
|
1159
|
+
if "loopx_codex_usable" not in codex_probe_stdout:
|
|
1160
|
+
runtime_probe = await self.exec_as_agent(
|
|
1161
|
+
environment,
|
|
1162
|
+
command=(
|
|
1163
|
+
agent_env_prefix
|
|
1164
|
+
+ "if command -v node >/dev/null 2>&1 && "
|
|
1165
|
+
"command -v npm >/dev/null 2>&1; then "
|
|
1166
|
+
" printf 'loopx_node_npm_ready\\n'; "
|
|
1167
|
+
"else "
|
|
1168
|
+
" printf 'loopx_node_npm_missing\\n'; "
|
|
1169
|
+
"fi"
|
|
1170
|
+
),
|
|
1171
|
+
)
|
|
1172
|
+
runtime_probe_stdout = str(
|
|
1173
|
+
getattr(runtime_probe, "stdout", "") or ""
|
|
1174
|
+
)
|
|
1175
|
+
if "loopx_node_npm_ready" not in runtime_probe_stdout:
|
|
1176
|
+
setup_stage = "agent_codex_install_node_path_repair"
|
|
1177
|
+
await self._repair_agent_node_runtime_path(environment)
|
|
1178
|
+
runtime_probe = await self.exec_as_agent(
|
|
1179
|
+
environment,
|
|
1180
|
+
command=(
|
|
1181
|
+
agent_env_prefix
|
|
1182
|
+
+ "hash -r; "
|
|
1183
|
+
+ "if command -v node >/dev/null 2>&1 && "
|
|
1184
|
+
"command -v npm >/dev/null 2>&1; then "
|
|
1185
|
+
" printf 'loopx_node_npm_ready\\n'; "
|
|
1186
|
+
"else "
|
|
1187
|
+
" printf 'loopx_node_npm_missing\\n'; "
|
|
1188
|
+
"fi"
|
|
1189
|
+
),
|
|
1190
|
+
)
|
|
1191
|
+
runtime_probe_stdout = str(
|
|
1192
|
+
getattr(runtime_probe, "stdout", "") or ""
|
|
1193
|
+
)
|
|
1194
|
+
if "loopx_node_npm_ready" in runtime_probe_stdout:
|
|
1195
|
+
setup_stage = "agent_codex_install_npm_existing"
|
|
1196
|
+
await self.exec_as_agent(
|
|
1197
|
+
environment,
|
|
1198
|
+
command=(
|
|
1199
|
+
agent_env_prefix
|
|
1200
|
+
+ 'mkdir -p "$NPM_CONFIG_PREFIX" && '
|
|
1201
|
+
f'npm install -g --registry "$NPM_CONFIG_REGISTRY" @openai/codex{version_spec}'
|
|
1202
|
+
),
|
|
1203
|
+
)
|
|
1204
|
+
else:
|
|
1205
|
+
setup_stage = "agent_codex_install_nvm_bootstrap"
|
|
1206
|
+
await self.exec_as_agent(
|
|
1207
|
+
environment,
|
|
1208
|
+
command=(
|
|
1209
|
+
"set -euo pipefail; "
|
|
1210
|
+
"command -v curl >/dev/null 2>&1 || "
|
|
1211
|
+
"{ echo 'Error: curl unavailable for NVM bootstrap' >&2; exit 1; }; "
|
|
1212
|
+
"curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.2/install.sh | bash"
|
|
1213
|
+
),
|
|
1214
|
+
)
|
|
1215
|
+
nvm_prefix = (
|
|
1216
|
+
agent_env_prefix
|
|
1217
|
+
+ 'export NVM_DIR="$HOME/.nvm"; '
|
|
1218
|
+
+ '[ -s "$NVM_DIR/nvm.sh" ] || '
|
|
1219
|
+
+ '{ echo "Error: NVM failed to install" >&2; exit 1; }; '
|
|
1220
|
+
+ '. "$NVM_DIR/nvm.sh"; '
|
|
1221
|
+
+ "command -v nvm >/dev/null 2>&1 || "
|
|
1222
|
+
+ "{ echo 'Error: NVM failed to load' >&2; exit 1; }; "
|
|
1223
|
+
)
|
|
1224
|
+
setup_stage = "agent_codex_install_nvm_node"
|
|
1225
|
+
await self.exec_as_agent(
|
|
1226
|
+
environment,
|
|
1227
|
+
command=nvm_prefix + "nvm install 22 && nvm alias default 22 && npm -v",
|
|
1228
|
+
)
|
|
1229
|
+
setup_stage = "agent_codex_install_npm_after_nvm"
|
|
1230
|
+
await self.exec_as_agent(
|
|
1231
|
+
environment,
|
|
1232
|
+
command=(
|
|
1233
|
+
nvm_prefix
|
|
1234
|
+
+ 'export NPM_CONFIG_PREFIX="${HOME}/.loopx-codex"; '
|
|
1235
|
+
+ 'export NPM_CONFIG_REGISTRY="${NPM_CONFIG_REGISTRY:-https://registry.npmjs.org}"; '
|
|
1236
|
+
+ 'export PATH="${NPM_CONFIG_PREFIX}/bin:${PATH}"; '
|
|
1237
|
+
+ 'mkdir -p "$NPM_CONFIG_PREFIX" && '
|
|
1238
|
+
+ f'npm install -g --registry "$NPM_CONFIG_REGISTRY" @openai/codex{version_spec}'
|
|
1239
|
+
),
|
|
1240
|
+
)
|
|
1241
|
+
setup_stage = "agent_codex_install_codex_version_probe"
|
|
1242
|
+
await self.exec_as_agent(
|
|
1243
|
+
environment,
|
|
1244
|
+
command=(
|
|
1245
|
+
agent_env_prefix
|
|
1246
|
+
+ "hash -r; codex --version >/dev/null 2>&1; codex --version"
|
|
1247
|
+
),
|
|
1248
|
+
)
|
|
1249
|
+
setup_stage = "root_codex_link"
|
|
1250
|
+
await self.exec_as_root(
|
|
1251
|
+
environment,
|
|
1252
|
+
command=(
|
|
1253
|
+
"for bin in node npm codex; do"
|
|
1254
|
+
' BIN_PATH="$(which "$bin" 2>/dev/null || true)";'
|
|
1255
|
+
' if [ -z "$BIN_PATH" ]; then'
|
|
1256
|
+
" for dir in "
|
|
1257
|
+
"/home/*/.loopx-codex/bin "
|
|
1258
|
+
"/root/.loopx-codex/bin "
|
|
1259
|
+
"/home/*/.nvm/versions/node/*/bin "
|
|
1260
|
+
"/root/.nvm/versions/node/*/bin; do"
|
|
1261
|
+
' if [ -x "$dir/$bin" ]; then BIN_PATH="$dir/$bin"; break; fi;'
|
|
1262
|
+
" done;"
|
|
1263
|
+
" fi;"
|
|
1264
|
+
' if [ -n "$BIN_PATH" ] && [ "$BIN_PATH" != "/usr/local/bin/$bin" ]; then'
|
|
1265
|
+
' ln -sf "$BIN_PATH" "/usr/local/bin/$bin";'
|
|
1266
|
+
" fi;"
|
|
1267
|
+
" done"
|
|
1268
|
+
),
|
|
1269
|
+
)
|
|
1270
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
1271
|
+
interrupted=False,
|
|
1272
|
+
interrupt_reason="codex_runtime_install_or_preflight_ok",
|
|
1273
|
+
checkpoint_kind="pre_worker_setup_install",
|
|
1274
|
+
codex_path_observed=None,
|
|
1275
|
+
)
|
|
1276
|
+
except Exception:
|
|
1277
|
+
stage_marker = self._read_loopx_setup_stage_marker()
|
|
1278
|
+
blocker_stage = (
|
|
1279
|
+
stage_marker
|
|
1280
|
+
if setup_stage == "agent_codex_install" and stage_marker
|
|
1281
|
+
else setup_stage
|
|
1282
|
+
)
|
|
1283
|
+
blocker = f"worker_install_failed_{blocker_stage}"
|
|
1284
|
+
self._best_effort_loopx_setup_diagnostic(
|
|
1285
|
+
interrupted=True,
|
|
1286
|
+
interrupt_reason=blocker,
|
|
1287
|
+
checkpoint_kind="pre_worker_setup_install",
|
|
1288
|
+
codex_path_observed=None,
|
|
1289
|
+
)
|
|
1290
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
1291
|
+
interrupted=True,
|
|
1292
|
+
interrupt_reason=blocker,
|
|
1293
|
+
checkpoint_kind="pre_worker_startup_blocker",
|
|
1294
|
+
)
|
|
1295
|
+
raise
|
|
1296
|
+
|
|
1297
|
+
def _active_loopx_cli_bridge(self) -> bool:
|
|
1298
|
+
return (
|
|
1299
|
+
self.loopx_mode == CODEX_LOOPX_MODE
|
|
1300
|
+
and self.loopx_cli_bridge_enabled
|
|
1301
|
+
and self.loopx_access_packet_mode
|
|
1302
|
+
!= TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
1303
|
+
)
|
|
1304
|
+
|
|
1305
|
+
def _hardened_codex_baseline(self) -> bool:
|
|
1306
|
+
return (
|
|
1307
|
+
self.loopx_mode in TERMINAL_BENCH_HARDENED_CODEX_BASELINE_MODES
|
|
1308
|
+
and self.loopx_access_packet_mode
|
|
1309
|
+
== TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
1310
|
+
)
|
|
1311
|
+
|
|
1312
|
+
def _codex_goal_mode_baseline(self) -> bool:
|
|
1313
|
+
return (
|
|
1314
|
+
self.loopx_mode == CODEX_GOAL_MODE_BASELINE_MODE
|
|
1315
|
+
and self.loopx_access_packet_mode
|
|
1316
|
+
== TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
1317
|
+
)
|
|
1318
|
+
|
|
1319
|
+
def _benchmark_case_active_state_required(self) -> bool:
|
|
1320
|
+
return not (self._hardened_codex_baseline() or self._codex_goal_mode_baseline())
|
|
1321
|
+
|
|
1322
|
+
def _host_worker_bridge_artifact_path(self, path: str | Path | None) -> Path | None:
|
|
1323
|
+
"""Map default in-container worker artifact paths to Harbor's host log dir."""
|
|
1324
|
+
|
|
1325
|
+
if not path:
|
|
1326
|
+
return None
|
|
1327
|
+
text = str(path)
|
|
1328
|
+
prefix = DEFAULT_WORKER_BRIDGE_TRACE_DIR.rstrip("/") + "/"
|
|
1329
|
+
if text.startswith(prefix):
|
|
1330
|
+
try:
|
|
1331
|
+
return Path(self.logs_dir) / text[len(prefix) :]
|
|
1332
|
+
except Exception:
|
|
1333
|
+
return Path(text)
|
|
1334
|
+
return Path(text)
|
|
1335
|
+
|
|
1336
|
+
def _load_loopx_trace_rows(self) -> list[dict[str, Any]]:
|
|
1337
|
+
host_trace_path = self._host_worker_bridge_artifact_path(
|
|
1338
|
+
self.loopx_counter_trace_json
|
|
1339
|
+
)
|
|
1340
|
+
return (
|
|
1341
|
+
load_loopx_counter_trace_file(host_trace_path)
|
|
1342
|
+
or self.loopx_counter_trace
|
|
1343
|
+
)
|
|
1344
|
+
|
|
1345
|
+
def _build_loopx_interaction_counters(
|
|
1346
|
+
self,
|
|
1347
|
+
trace_rows: list[dict[str, Any]],
|
|
1348
|
+
*,
|
|
1349
|
+
active_cli_bridge: bool,
|
|
1350
|
+
no_trace_case_result_writeback: str,
|
|
1351
|
+
no_trace_counter_trust_level: str,
|
|
1352
|
+
) -> dict[str, Any]:
|
|
1353
|
+
no_trace_prompt_only = (
|
|
1354
|
+
self.loopx_mode == CODEX_LOOPX_MODE
|
|
1355
|
+
and not active_cli_bridge
|
|
1356
|
+
and not self.loopx_counter_trace
|
|
1357
|
+
)
|
|
1358
|
+
hardened_baseline = self._hardened_codex_baseline()
|
|
1359
|
+
goal_mode_baseline = self._codex_goal_mode_baseline()
|
|
1360
|
+
counters = extract_loopx_interaction_counters_from_trace(
|
|
1361
|
+
trace_rows,
|
|
1362
|
+
prompt_policy_injected=not (hardened_baseline or goal_mode_baseline),
|
|
1363
|
+
harness_skill_or_packet_injected=bool(
|
|
1364
|
+
self._loopx_context_metadata.get(
|
|
1365
|
+
"loopx_access_packet_injected"
|
|
1366
|
+
)
|
|
1367
|
+
),
|
|
1368
|
+
case_result_writeback=(
|
|
1369
|
+
no_trace_case_result_writeback
|
|
1370
|
+
if active_cli_bridge and not trace_rows
|
|
1371
|
+
else "codex_goal_mode_baseline_runner_only"
|
|
1372
|
+
if goal_mode_baseline
|
|
1373
|
+
else "hardened_codex_baseline_runner_only"
|
|
1374
|
+
if hardened_baseline
|
|
1375
|
+
else "not_observed_prompt_only_no_cli_bridge"
|
|
1376
|
+
if no_trace_prompt_only
|
|
1377
|
+
else "not_observed_custom_agent_metadata"
|
|
1378
|
+
),
|
|
1379
|
+
no_trace_counter_trust_level=(
|
|
1380
|
+
no_trace_counter_trust_level
|
|
1381
|
+
if active_cli_bridge and not trace_rows
|
|
1382
|
+
else "codex_goal_mode_baseline_no_loopx_state"
|
|
1383
|
+
if goal_mode_baseline
|
|
1384
|
+
else "hardened_codex_baseline_no_loopx_state"
|
|
1385
|
+
if hardened_baseline
|
|
1386
|
+
else "runtime_metadata_prompt_only_no_cli_bridge"
|
|
1387
|
+
if no_trace_prompt_only
|
|
1388
|
+
else "runtime_metadata_no_trace_observed"
|
|
1389
|
+
),
|
|
1390
|
+
)
|
|
1391
|
+
if self._benchmark_case_active_state_required():
|
|
1392
|
+
initialized = bool(
|
|
1393
|
+
self._loopx_context_metadata.get(
|
|
1394
|
+
"case_goal_state_initialized_before_agent"
|
|
1395
|
+
)
|
|
1396
|
+
)
|
|
1397
|
+
counters.update(
|
|
1398
|
+
{
|
|
1399
|
+
"case_goal_state_packet_present": True,
|
|
1400
|
+
"case_goal_state_init_required": True,
|
|
1401
|
+
"case_goal_state_initialized_before_agent": initialized,
|
|
1402
|
+
"case_goal_state_init_status": str(
|
|
1403
|
+
self._loopx_context_metadata.get(
|
|
1404
|
+
"case_goal_state_init_status"
|
|
1405
|
+
)
|
|
1406
|
+
or "not_started"
|
|
1407
|
+
),
|
|
1408
|
+
"case_goal_state_schema_version": BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
1409
|
+
"case_goal_state_path": TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1410
|
+
"loopx_case_state_reads": 0,
|
|
1411
|
+
"loopx_case_state_writes": 1 if initialized else 0,
|
|
1412
|
+
"loopx_case_state_path_count": 1,
|
|
1413
|
+
}
|
|
1414
|
+
)
|
|
1415
|
+
return counters
|
|
1416
|
+
|
|
1417
|
+
def _write_loopx_worker_benchmark_run_checkpoint(
|
|
1418
|
+
self,
|
|
1419
|
+
*,
|
|
1420
|
+
interrupted: bool,
|
|
1421
|
+
interrupt_reason: str,
|
|
1422
|
+
checkpoint_kind: str,
|
|
1423
|
+
) -> tuple[dict[str, Any] | None, bool, str]:
|
|
1424
|
+
active_cli_bridge = self._active_loopx_cli_bridge()
|
|
1425
|
+
benchmark_run_json_declared = bool(self.loopx_benchmark_run_json)
|
|
1426
|
+
if not active_cli_bridge:
|
|
1427
|
+
return None, False, "not_enabled"
|
|
1428
|
+
if not benchmark_run_json_declared:
|
|
1429
|
+
return None, False, "worker_bridge_benchmark_run_path_missing"
|
|
1430
|
+
|
|
1431
|
+
trace_rows = self._load_loopx_trace_rows()
|
|
1432
|
+
interaction_counters = self._build_loopx_interaction_counters(
|
|
1433
|
+
trace_rows,
|
|
1434
|
+
active_cli_bridge=active_cli_bridge,
|
|
1435
|
+
no_trace_case_result_writeback=(
|
|
1436
|
+
"worker_bridge_run_finally_checkpoint_no_trace"
|
|
1437
|
+
if checkpoint_kind == "run_finally"
|
|
1438
|
+
else "not_observed_active_cli_bridge_no_trace"
|
|
1439
|
+
),
|
|
1440
|
+
no_trace_counter_trust_level=(
|
|
1441
|
+
"run_finally_active_cli_bridge_no_trace_observed"
|
|
1442
|
+
if checkpoint_kind == "run_finally"
|
|
1443
|
+
else "runtime_metadata_active_cli_bridge_no_trace_observed"
|
|
1444
|
+
),
|
|
1445
|
+
)
|
|
1446
|
+
payload = build_worker_bridge_benchmark_run_from_counters(
|
|
1447
|
+
interaction_counters,
|
|
1448
|
+
counter_trace_present=bool(trace_rows),
|
|
1449
|
+
source_runner="terminal_bench_worker_bridge",
|
|
1450
|
+
benchmark_id="terminal-bench-worker-bridge@v0",
|
|
1451
|
+
job_name="terminal_bench_loopx_active_worker",
|
|
1452
|
+
task_id="terminal-bench-worker-bridge",
|
|
1453
|
+
trial_name=f"terminal-bench-worker-bridge-{checkpoint_kind}",
|
|
1454
|
+
interrupted=interrupted,
|
|
1455
|
+
interrupt_reason=interrupt_reason,
|
|
1456
|
+
)
|
|
1457
|
+
payload["episode_policy"] = build_terminal_bench_single_agent_episode_policy(
|
|
1458
|
+
active_cli_bridge=True,
|
|
1459
|
+
runner_side_guaranteed_writeback=True,
|
|
1460
|
+
)
|
|
1461
|
+
payload["worker_bridge_checkpoint"] = {
|
|
1462
|
+
"schema_version": "loopx_worker_bridge_checkpoint_v0",
|
|
1463
|
+
"checkpoint_kind": checkpoint_kind,
|
|
1464
|
+
"interrupted": bool(interrupted),
|
|
1465
|
+
"trace_row_count": len(trace_rows),
|
|
1466
|
+
"raw_trace_recorded": False,
|
|
1467
|
+
"raw_paths_recorded": False,
|
|
1468
|
+
}
|
|
1469
|
+
if checkpoint_kind == "pre_worker_startup_blocker":
|
|
1470
|
+
blocker = interrupt_reason.strip() or "pre_worker_startup_failure"
|
|
1471
|
+
payload["first_blocker"] = blocker
|
|
1472
|
+
payload["repeat_blocked_by"] = blocker
|
|
1473
|
+
payload["pre_worker_startup_blocker"] = blocker
|
|
1474
|
+
payload["worker_bridge_checkpoint"]["pre_worker_startup_blocker"] = blocker
|
|
1475
|
+
payload["worker_bridge_outcome"]["pre_worker_startup_blocker"] = blocker
|
|
1476
|
+
payload["worker_bridge_outcome"][
|
|
1477
|
+
"next_action"
|
|
1478
|
+
] = "repair worker runtime preflight/startup before repeat"
|
|
1479
|
+
payload["validation"]["worker_startup_blocker_recorded"] = True
|
|
1480
|
+
payload["validation"][
|
|
1481
|
+
"runner_return_completed_or_blocker_recorded"
|
|
1482
|
+
] = True
|
|
1483
|
+
written = write_worker_bridge_benchmark_run_file(
|
|
1484
|
+
self._host_worker_bridge_artifact_path(
|
|
1485
|
+
self.loopx_benchmark_run_json
|
|
1486
|
+
),
|
|
1487
|
+
payload,
|
|
1488
|
+
)
|
|
1489
|
+
status = (
|
|
1490
|
+
"worker_bridge_benchmark_run_written"
|
|
1491
|
+
if written
|
|
1492
|
+
else "worker_bridge_benchmark_run_write_failed"
|
|
1493
|
+
)
|
|
1494
|
+
return payload, written, status
|
|
1495
|
+
|
|
1496
|
+
def _best_effort_loopx_worker_bridge_checkpoint(
|
|
1497
|
+
self,
|
|
1498
|
+
*,
|
|
1499
|
+
interrupted: bool,
|
|
1500
|
+
interrupt_reason: str,
|
|
1501
|
+
checkpoint_kind: str,
|
|
1502
|
+
) -> tuple[dict[str, Any] | None, bool, str]:
|
|
1503
|
+
try:
|
|
1504
|
+
return self._write_loopx_worker_benchmark_run_checkpoint(
|
|
1505
|
+
interrupted=interrupted,
|
|
1506
|
+
interrupt_reason=interrupt_reason,
|
|
1507
|
+
checkpoint_kind=checkpoint_kind,
|
|
1508
|
+
)
|
|
1509
|
+
except Exception:
|
|
1510
|
+
logger = getattr(self, "logger", None)
|
|
1511
|
+
if logger is not None:
|
|
1512
|
+
logger.exception("LoopX worker checkpoint write failed")
|
|
1513
|
+
return None, False, "worker_bridge_benchmark_run_checkpoint_failed"
|
|
1514
|
+
|
|
1515
|
+
async def _ensure_loopx_worker_bridge_runtime(
|
|
1516
|
+
self,
|
|
1517
|
+
environment: BaseEnvironment,
|
|
1518
|
+
) -> str:
|
|
1519
|
+
if not (
|
|
1520
|
+
self.loopx_mode == CODEX_LOOPX_MODE
|
|
1521
|
+
and self.loopx_cli_bridge_enabled
|
|
1522
|
+
and self.loopx_access_packet_mode
|
|
1523
|
+
!= TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
1524
|
+
):
|
|
1525
|
+
return "not_applicable"
|
|
1526
|
+
if not self.loopx_runtime_preflight_command:
|
|
1527
|
+
return "not_configured"
|
|
1528
|
+
|
|
1529
|
+
exec_as_root = getattr(self, "exec_as_root", None)
|
|
1530
|
+
if exec_as_root is None:
|
|
1531
|
+
return "not_supported_by_agent_base"
|
|
1532
|
+
|
|
1533
|
+
await exec_as_root(
|
|
1534
|
+
environment,
|
|
1535
|
+
command=self.loopx_runtime_preflight_command,
|
|
1536
|
+
timeout_sec=300,
|
|
1537
|
+
)
|
|
1538
|
+
return "passed"
|
|
1539
|
+
|
|
1540
|
+
async def _initialize_benchmark_case_active_state(
|
|
1541
|
+
self,
|
|
1542
|
+
environment: BaseEnvironment,
|
|
1543
|
+
instruction: str,
|
|
1544
|
+
) -> dict[str, Any]:
|
|
1545
|
+
"""Initialize the canonical benchmark case active-state before Codex runs."""
|
|
1546
|
+
|
|
1547
|
+
required = self._benchmark_case_active_state_required()
|
|
1548
|
+
if not required:
|
|
1549
|
+
return {
|
|
1550
|
+
"case_goal_state_init_required": False,
|
|
1551
|
+
"case_goal_state_initialized_before_agent": False,
|
|
1552
|
+
"case_goal_state_init_status": "not_applicable",
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
exec_as_root = getattr(self, "exec_as_root", None)
|
|
1556
|
+
if exec_as_root is None:
|
|
1557
|
+
return {
|
|
1558
|
+
"case_goal_state_init_required": True,
|
|
1559
|
+
"case_goal_state_initialized_before_agent": False,
|
|
1560
|
+
"case_goal_state_init_status": "not_supported_by_agent_base",
|
|
1561
|
+
"case_goal_state_path": TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1562
|
+
"case_goal_state_schema_version": BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
1563
|
+
}
|
|
1564
|
+
|
|
1565
|
+
content = benchmark_case_active_state_seed_text(
|
|
1566
|
+
benchmark_name="Terminal-Bench",
|
|
1567
|
+
goal_id=TERMINAL_BENCH_CASE_GOAL_ID,
|
|
1568
|
+
task_id=f"terminal-bench-task-{_task_hash(instruction)}",
|
|
1569
|
+
route=self.loopx_mode,
|
|
1570
|
+
max_rounds=1,
|
|
1571
|
+
case_state_path=TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1572
|
+
)
|
|
1573
|
+
command = benchmark_case_active_state_write_command(
|
|
1574
|
+
case_state_path=TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1575
|
+
content=content,
|
|
1576
|
+
)
|
|
1577
|
+
result = await exec_as_root(environment, command=command, timeout_sec=30)
|
|
1578
|
+
return_code = int(getattr(result, "return_code", 1))
|
|
1579
|
+
if return_code != 0:
|
|
1580
|
+
return {
|
|
1581
|
+
"case_goal_state_init_required": True,
|
|
1582
|
+
"case_goal_state_initialized_before_agent": False,
|
|
1583
|
+
"case_goal_state_init_status": "failed",
|
|
1584
|
+
"case_goal_state_init_rc": return_code,
|
|
1585
|
+
"case_goal_state_path": TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1586
|
+
"case_goal_state_schema_version": BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
1587
|
+
}
|
|
1588
|
+
|
|
1589
|
+
return {
|
|
1590
|
+
"case_goal_state_init_required": True,
|
|
1591
|
+
"case_goal_state_initialized_before_agent": True,
|
|
1592
|
+
"case_goal_state_init_status": "passed",
|
|
1593
|
+
"case_goal_state_init_rc": return_code,
|
|
1594
|
+
"case_goal_state_path": TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1595
|
+
"case_goal_state_schema_version": BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION,
|
|
1596
|
+
}
|
|
1597
|
+
|
|
1598
|
+
async def run(
|
|
1599
|
+
self,
|
|
1600
|
+
instruction: str,
|
|
1601
|
+
environment: BaseEnvironment,
|
|
1602
|
+
context: AgentContext,
|
|
1603
|
+
) -> None:
|
|
1604
|
+
hardened_baseline = self._hardened_codex_baseline()
|
|
1605
|
+
goal_mode_baseline = self._codex_goal_mode_baseline()
|
|
1606
|
+
baseline_without_loopx = hardened_baseline or goal_mode_baseline
|
|
1607
|
+
case_goal_state_required = not baseline_without_loopx
|
|
1608
|
+
managed_instruction = build_managed_terminal_bench_instruction(
|
|
1609
|
+
instruction,
|
|
1610
|
+
policy_version=self.loopx_policy_version,
|
|
1611
|
+
behavior_spec_id=self.loopx_behavior_spec_id,
|
|
1612
|
+
ablation_mode=self.loopx_ablation_mode,
|
|
1613
|
+
loopx_mode=self.loopx_mode,
|
|
1614
|
+
goal_id=self.loopx_goal_id,
|
|
1615
|
+
loopx_access_packet_mode=self.loopx_access_packet_mode,
|
|
1616
|
+
loopx_cli_bridge_enabled=self.loopx_cli_bridge_enabled,
|
|
1617
|
+
loopx_command_prefix=self.loopx_command_prefix,
|
|
1618
|
+
loopx_registry_arg=self.loopx_registry_arg,
|
|
1619
|
+
loopx_runtime_root_arg=self.loopx_runtime_root_arg,
|
|
1620
|
+
loopx_scan_path=self.loopx_scan_path,
|
|
1621
|
+
loopx_benchmark_run_json=self.loopx_benchmark_run_json,
|
|
1622
|
+
loopx_counter_trace_json=self.loopx_counter_trace_json,
|
|
1623
|
+
loopx_classification=self.loopx_classification,
|
|
1624
|
+
loopx_append_execute_enabled=self.loopx_append_execute_enabled,
|
|
1625
|
+
loopx_active_user_intervention_enabled=(
|
|
1626
|
+
self.loopx_active_user_intervention_enabled
|
|
1627
|
+
),
|
|
1628
|
+
loopx_active_user_feed_jsonl=self.loopx_active_user_feed_jsonl,
|
|
1629
|
+
loopx_active_user_observation_json=(
|
|
1630
|
+
self.loopx_active_user_observation_json
|
|
1631
|
+
),
|
|
1632
|
+
loopx_active_user_observe_command=(
|
|
1633
|
+
self.loopx_active_user_observe_command
|
|
1634
|
+
),
|
|
1635
|
+
loopx_active_user_channel_surface=(
|
|
1636
|
+
self.loopx_active_user_channel_surface
|
|
1637
|
+
),
|
|
1638
|
+
loopx_case_state_path=TERMINAL_BENCH_CASE_STATE_PATH,
|
|
1639
|
+
loopx_case_state_schema_version=(
|
|
1640
|
+
BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION
|
|
1641
|
+
),
|
|
1642
|
+
loopx_case_state_required=case_goal_state_required,
|
|
1643
|
+
)
|
|
1644
|
+
access_packet_injected = (
|
|
1645
|
+
self.loopx_mode == CODEX_LOOPX_MODE
|
|
1646
|
+
and self.loopx_access_packet_mode
|
|
1647
|
+
!= TERMINAL_BENCH_LOOPX_ACCESS_PACKET_MODE_NONE
|
|
1648
|
+
)
|
|
1649
|
+
interface_surface = (
|
|
1650
|
+
TERMINAL_BENCH_HARDENED_CODEX_BASELINE_SURFACE
|
|
1651
|
+
if hardened_baseline
|
|
1652
|
+
else TERMINAL_BENCH_CODEX_GOAL_MODE_BASELINE_SURFACE
|
|
1653
|
+
if goal_mode_baseline
|
|
1654
|
+
else
|
|
1655
|
+
TERMINAL_BENCH_CODEX_WORKER_CLI_BRIDGE_SURFACE
|
|
1656
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1657
|
+
else TERMINAL_BENCH_LOOPX_INTERFACE_SURFACE
|
|
1658
|
+
if access_packet_injected
|
|
1659
|
+
else "managed_policy_prompt_only"
|
|
1660
|
+
)
|
|
1661
|
+
self._loopx_context_metadata = {
|
|
1662
|
+
"mode": self.loopx_mode,
|
|
1663
|
+
"policy_version": self.loopx_policy_version,
|
|
1664
|
+
"behavior_spec_id": self.loopx_behavior_spec_id,
|
|
1665
|
+
"ablation_mode": self.loopx_ablation_mode,
|
|
1666
|
+
"loopx_access_packet_mode": self.loopx_access_packet_mode,
|
|
1667
|
+
"trace_publicness": self.loopx_trace_publicness,
|
|
1668
|
+
"loopx_codex_preflight_timeout_sec": (
|
|
1669
|
+
self.loopx_codex_preflight_timeout_sec
|
|
1670
|
+
),
|
|
1671
|
+
"loopx_access_packet_injected": access_packet_injected,
|
|
1672
|
+
"loopx_interface_surface": interface_surface,
|
|
1673
|
+
"loopx_cli_bridge_available": (
|
|
1674
|
+
True
|
|
1675
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1676
|
+
else TERMINAL_BENCH_LOOPX_CLI_BRIDGE_AVAILABLE
|
|
1677
|
+
if access_packet_injected
|
|
1678
|
+
else False
|
|
1679
|
+
),
|
|
1680
|
+
"loopx_cli_bridge_contract": (
|
|
1681
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CONTRACT_VERSION
|
|
1682
|
+
if access_packet_injected
|
|
1683
|
+
else None
|
|
1684
|
+
),
|
|
1685
|
+
"loopx_active_user_intervention_enabled": (
|
|
1686
|
+
self.loopx_active_user_intervention_enabled
|
|
1687
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1688
|
+
else False
|
|
1689
|
+
),
|
|
1690
|
+
"loopx_active_user_channel_surface": (
|
|
1691
|
+
self.loopx_active_user_channel_surface
|
|
1692
|
+
if self.loopx_active_user_intervention_enabled
|
|
1693
|
+
else None
|
|
1694
|
+
),
|
|
1695
|
+
"loopx_active_user_feed_declared": (
|
|
1696
|
+
bool(self.loopx_active_user_feed_jsonl)
|
|
1697
|
+
if self.loopx_active_user_intervention_enabled
|
|
1698
|
+
else False
|
|
1699
|
+
),
|
|
1700
|
+
"loopx_active_user_observe_command_declared": (
|
|
1701
|
+
bool(self.loopx_active_user_observe_command)
|
|
1702
|
+
if self.loopx_active_user_intervention_enabled
|
|
1703
|
+
else False
|
|
1704
|
+
),
|
|
1705
|
+
"loopx_prompt_only_until_cli_bridge": (
|
|
1706
|
+
access_packet_injected
|
|
1707
|
+
and not self.loopx_cli_bridge_enabled
|
|
1708
|
+
and not TERMINAL_BENCH_LOOPX_CLI_BRIDGE_AVAILABLE
|
|
1709
|
+
),
|
|
1710
|
+
"available_loopx_interface_commands": (
|
|
1711
|
+
list(TERMINAL_BENCH_LOOPX_ACCESS_PACKET_COMMANDS)
|
|
1712
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1713
|
+
else []
|
|
1714
|
+
),
|
|
1715
|
+
"loopx_cli_bridge_call_policy_version": (
|
|
1716
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CALL_POLICY_VERSION
|
|
1717
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1718
|
+
else None
|
|
1719
|
+
),
|
|
1720
|
+
"loopx_cli_bridge_call_policy_mode": (
|
|
1721
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_CALL_POLICY_MODE
|
|
1722
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1723
|
+
else None
|
|
1724
|
+
),
|
|
1725
|
+
"loopx_cli_bridge_default_required_calls": (
|
|
1726
|
+
list(TERMINAL_BENCH_LOOPX_CLI_BRIDGE_DEFAULT_REQUIRED_CALLS)
|
|
1727
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1728
|
+
else []
|
|
1729
|
+
),
|
|
1730
|
+
"loopx_cli_bridge_optional_context_calls": (
|
|
1731
|
+
list(TERMINAL_BENCH_LOOPX_CLI_BRIDGE_OPTIONAL_CONTEXT_CALLS)
|
|
1732
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1733
|
+
else []
|
|
1734
|
+
),
|
|
1735
|
+
"loopx_cli_bridge_required_call_minimum": (
|
|
1736
|
+
TERMINAL_BENCH_LOOPX_CLI_BRIDGE_REQUIRED_CALL_MINIMUM
|
|
1737
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1738
|
+
else 0
|
|
1739
|
+
),
|
|
1740
|
+
"loopx_cli_bridge_command_prefix_present": (
|
|
1741
|
+
bool(self.loopx_command_prefix)
|
|
1742
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1743
|
+
else False
|
|
1744
|
+
),
|
|
1745
|
+
"loopx_cli_bridge_append_execute_enabled": (
|
|
1746
|
+
self.loopx_append_execute_enabled
|
|
1747
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1748
|
+
else False
|
|
1749
|
+
),
|
|
1750
|
+
"loopx_counter_trace_jsonl_declared": (
|
|
1751
|
+
bool(self.loopx_counter_trace_json)
|
|
1752
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1753
|
+
else False
|
|
1754
|
+
),
|
|
1755
|
+
"loopx_benchmark_run_schema_version": (
|
|
1756
|
+
self.loopx_benchmark_run_schema_version
|
|
1757
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1758
|
+
else None
|
|
1759
|
+
),
|
|
1760
|
+
"loopx_benchmark_run_writeback_contract": (
|
|
1761
|
+
self.loopx_benchmark_run_writeback_contract
|
|
1762
|
+
if access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1763
|
+
else None
|
|
1764
|
+
),
|
|
1765
|
+
"declared_loopx_interface_commands": (
|
|
1766
|
+
list(TERMINAL_BENCH_LOOPX_ACCESS_PACKET_COMMANDS)
|
|
1767
|
+
if access_packet_injected
|
|
1768
|
+
else []
|
|
1769
|
+
),
|
|
1770
|
+
"loopx_access_packet_schema_version": (
|
|
1771
|
+
TERMINAL_BENCH_LOOPX_ACCESS_PACKET_VERSION
|
|
1772
|
+
if access_packet_injected
|
|
1773
|
+
else None
|
|
1774
|
+
),
|
|
1775
|
+
"loopx_episode_policy": build_terminal_bench_single_agent_episode_policy(
|
|
1776
|
+
active_cli_bridge=bool(
|
|
1777
|
+
access_packet_injected and self.loopx_cli_bridge_enabled
|
|
1778
|
+
),
|
|
1779
|
+
runner_side_guaranteed_writeback=True,
|
|
1780
|
+
),
|
|
1781
|
+
"case_semantics_changed_by_harness": not baseline_without_loopx,
|
|
1782
|
+
"loopx_inside_case": not baseline_without_loopx,
|
|
1783
|
+
"official_score_comparable_to_native_codex": False,
|
|
1784
|
+
"official_score_comparable_to_loopx_treatment": baseline_without_loopx,
|
|
1785
|
+
"model_plus_harness_pair": not baseline_without_loopx,
|
|
1786
|
+
"control_plane_score_applicable": not baseline_without_loopx,
|
|
1787
|
+
"startup_surface_calibration": False,
|
|
1788
|
+
"hardened_install_surface": hardened_baseline,
|
|
1789
|
+
"hardened_install_baseline": hardened_baseline,
|
|
1790
|
+
"codex_goal_mode_baseline": goal_mode_baseline,
|
|
1791
|
+
"codex_goal_mode_invocation_surface": (
|
|
1792
|
+
"slash_command" if goal_mode_baseline else None
|
|
1793
|
+
),
|
|
1794
|
+
"task_prompt_changed_by_loopx_policy": not baseline_without_loopx,
|
|
1795
|
+
"raw_task_instruction_recorded": False,
|
|
1796
|
+
"raw_managed_prompt_recorded": False,
|
|
1797
|
+
"raw_interaction_trace_recorded": False,
|
|
1798
|
+
"task_instruction_sha256_16": _task_hash(instruction),
|
|
1799
|
+
"managed_prompt_chars": len(managed_instruction),
|
|
1800
|
+
"context_metadata_deferred_until_post_run": True,
|
|
1801
|
+
"case_goal_state_init_required": case_goal_state_required,
|
|
1802
|
+
"case_goal_state_initialized_before_agent": False,
|
|
1803
|
+
"case_goal_state_init_status": (
|
|
1804
|
+
"not_started" if case_goal_state_required else "not_applicable"
|
|
1805
|
+
),
|
|
1806
|
+
"case_goal_state_path": (
|
|
1807
|
+
TERMINAL_BENCH_CASE_STATE_PATH if case_goal_state_required else None
|
|
1808
|
+
),
|
|
1809
|
+
"case_goal_state_schema_version": (
|
|
1810
|
+
BENCHMARK_CASE_ACTIVE_STATE_SCHEMA_VERSION
|
|
1811
|
+
if case_goal_state_required
|
|
1812
|
+
else None
|
|
1813
|
+
),
|
|
1814
|
+
}
|
|
1815
|
+
self._loopx_context_metadata[
|
|
1816
|
+
"loopx_runtime_preflight_status"
|
|
1817
|
+
] = "not_started"
|
|
1818
|
+
if self.loopx_worker_materialization_probe_only:
|
|
1819
|
+
try:
|
|
1820
|
+
runtime_preflight_status = (
|
|
1821
|
+
await self._ensure_loopx_worker_bridge_runtime(environment)
|
|
1822
|
+
)
|
|
1823
|
+
except Exception:
|
|
1824
|
+
self._loopx_context_metadata.update(
|
|
1825
|
+
{
|
|
1826
|
+
"loopx_runtime_preflight_status": "failed",
|
|
1827
|
+
"loopx_pre_worker_startup_blocker": (
|
|
1828
|
+
"runtime_preflight_failed"
|
|
1829
|
+
),
|
|
1830
|
+
}
|
|
1831
|
+
)
|
|
1832
|
+
_, probe_written, probe_status = (
|
|
1833
|
+
self._write_loopx_worker_materialization_probe_result(
|
|
1834
|
+
interface_surface=interface_surface,
|
|
1835
|
+
runtime_preflight_status="failed",
|
|
1836
|
+
interrupted=True,
|
|
1837
|
+
interrupt_reason="runtime_preflight_failed",
|
|
1838
|
+
)
|
|
1839
|
+
)
|
|
1840
|
+
self._loopx_context_metadata.update(
|
|
1841
|
+
{
|
|
1842
|
+
"worker_materialization_probe_only": True,
|
|
1843
|
+
"worker_materialization_probe_written": probe_written,
|
|
1844
|
+
"worker_materialization_probe_writeback_status": probe_status,
|
|
1845
|
+
}
|
|
1846
|
+
)
|
|
1847
|
+
raise
|
|
1848
|
+
self._loopx_context_metadata[
|
|
1849
|
+
"loopx_runtime_preflight_status"
|
|
1850
|
+
] = runtime_preflight_status
|
|
1851
|
+
_, probe_written, probe_status = (
|
|
1852
|
+
self._write_loopx_worker_materialization_probe_result(
|
|
1853
|
+
interface_surface=interface_surface,
|
|
1854
|
+
runtime_preflight_status=runtime_preflight_status,
|
|
1855
|
+
)
|
|
1856
|
+
)
|
|
1857
|
+
case_state_probe_status: dict[str, Any] = {}
|
|
1858
|
+
if case_goal_state_required:
|
|
1859
|
+
case_state_probe_status = {
|
|
1860
|
+
"case_goal_state_initialized_before_agent": False,
|
|
1861
|
+
"case_goal_state_init_status": "not_applicable_probe_only",
|
|
1862
|
+
}
|
|
1863
|
+
self._loopx_context_metadata.update(
|
|
1864
|
+
{
|
|
1865
|
+
**case_state_probe_status,
|
|
1866
|
+
"worker_materialization_probe_only": True,
|
|
1867
|
+
"worker_materialization_probe_written": probe_written,
|
|
1868
|
+
"worker_materialization_probe_writeback_status": probe_status,
|
|
1869
|
+
"run_completed_or_interrupted": True,
|
|
1870
|
+
"agent_run_started": False,
|
|
1871
|
+
"agent_run_completed": False,
|
|
1872
|
+
"agent_run_interrupted": False,
|
|
1873
|
+
"credential_values_recorded": False,
|
|
1874
|
+
"auth_files_recorded": False,
|
|
1875
|
+
"leaderboard_evidence": False,
|
|
1876
|
+
"submit_eligible": False,
|
|
1877
|
+
}
|
|
1878
|
+
)
|
|
1879
|
+
return
|
|
1880
|
+
worker_run_started = False
|
|
1881
|
+
run_completed = False
|
|
1882
|
+
pre_worker_startup_blocker = "runtime_preflight_failed"
|
|
1883
|
+
try:
|
|
1884
|
+
try:
|
|
1885
|
+
runtime_preflight_status = (
|
|
1886
|
+
await self._ensure_loopx_worker_bridge_runtime(environment)
|
|
1887
|
+
)
|
|
1888
|
+
except Exception:
|
|
1889
|
+
self._loopx_context_metadata.update(
|
|
1890
|
+
{
|
|
1891
|
+
"loopx_runtime_preflight_status": "failed",
|
|
1892
|
+
"loopx_pre_worker_startup_blocker": (
|
|
1893
|
+
"runtime_preflight_failed"
|
|
1894
|
+
),
|
|
1895
|
+
}
|
|
1896
|
+
)
|
|
1897
|
+
raise
|
|
1898
|
+
self._loopx_context_metadata[
|
|
1899
|
+
"loopx_runtime_preflight_status"
|
|
1900
|
+
] = runtime_preflight_status
|
|
1901
|
+
case_state_init = await self._initialize_benchmark_case_active_state(
|
|
1902
|
+
environment,
|
|
1903
|
+
instruction,
|
|
1904
|
+
)
|
|
1905
|
+
self._loopx_context_metadata.update(case_state_init)
|
|
1906
|
+
if (
|
|
1907
|
+
case_goal_state_required
|
|
1908
|
+
and case_state_init.get("case_goal_state_init_status") != "passed"
|
|
1909
|
+
):
|
|
1910
|
+
pre_worker_startup_blocker = "case_goal_state_init_failed"
|
|
1911
|
+
self._loopx_context_metadata[
|
|
1912
|
+
"loopx_pre_worker_startup_blocker"
|
|
1913
|
+
] = pre_worker_startup_blocker
|
|
1914
|
+
raise RuntimeError("LoopX case active-state init failed")
|
|
1915
|
+
worker_run_started = True
|
|
1916
|
+
await super().run(managed_instruction, environment, context)
|
|
1917
|
+
run_completed = True
|
|
1918
|
+
finally:
|
|
1919
|
+
checkpoint_kind = (
|
|
1920
|
+
"run_finally" if worker_run_started else "pre_worker_startup_blocker"
|
|
1921
|
+
)
|
|
1922
|
+
interrupt_reason = (
|
|
1923
|
+
""
|
|
1924
|
+
if run_completed
|
|
1925
|
+
else "agent_run_exception_or_nonzero_exit"
|
|
1926
|
+
if worker_run_started
|
|
1927
|
+
else pre_worker_startup_blocker
|
|
1928
|
+
)
|
|
1929
|
+
self._loopx_context_metadata.update(
|
|
1930
|
+
{
|
|
1931
|
+
"run_completed_or_interrupted": True,
|
|
1932
|
+
"agent_run_started": worker_run_started,
|
|
1933
|
+
"agent_run_completed": run_completed,
|
|
1934
|
+
"agent_run_interrupted": not run_completed,
|
|
1935
|
+
"loopx_run_finally_checkpoint_kind": checkpoint_kind,
|
|
1936
|
+
"loopx_run_finally_interrupt_reason": interrupt_reason,
|
|
1937
|
+
"credential_values_recorded": False,
|
|
1938
|
+
"auth_files_recorded": False,
|
|
1939
|
+
"leaderboard_evidence": False,
|
|
1940
|
+
"submit_eligible": False,
|
|
1941
|
+
}
|
|
1942
|
+
)
|
|
1943
|
+
_, benchmark_run_written, benchmark_run_status = (
|
|
1944
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
1945
|
+
interrupted=not run_completed,
|
|
1946
|
+
interrupt_reason=interrupt_reason,
|
|
1947
|
+
checkpoint_kind=checkpoint_kind,
|
|
1948
|
+
)
|
|
1949
|
+
)
|
|
1950
|
+
self._loopx_context_metadata.update(
|
|
1951
|
+
{
|
|
1952
|
+
"loopx_run_finally_benchmark_run_json_written": (
|
|
1953
|
+
benchmark_run_written
|
|
1954
|
+
),
|
|
1955
|
+
"loopx_run_finally_benchmark_run_writeback_status": (
|
|
1956
|
+
benchmark_run_status
|
|
1957
|
+
),
|
|
1958
|
+
}
|
|
1959
|
+
)
|
|
1960
|
+
|
|
1961
|
+
def _populate_usage_from_session_token_count(self, context: AgentContext) -> bool:
|
|
1962
|
+
try:
|
|
1963
|
+
session_dir = self._get_session_dir()
|
|
1964
|
+
except Exception:
|
|
1965
|
+
self.logger.exception("Failed to locate Codex session directory")
|
|
1966
|
+
return False
|
|
1967
|
+
if not session_dir:
|
|
1968
|
+
return False
|
|
1969
|
+
|
|
1970
|
+
usage = extract_codex_session_usage(session_dir)
|
|
1971
|
+
if not usage:
|
|
1972
|
+
return False
|
|
1973
|
+
|
|
1974
|
+
context.n_input_tokens = usage.get("input_tokens")
|
|
1975
|
+
context.n_cache_tokens = usage.get("cache_tokens")
|
|
1976
|
+
context.n_output_tokens = usage.get("output_tokens")
|
|
1977
|
+
if context.cost_usd is None:
|
|
1978
|
+
context.cost_usd = self._compute_cost_from_pricing(
|
|
1979
|
+
prompt_tokens=context.n_input_tokens,
|
|
1980
|
+
completion_tokens=context.n_output_tokens,
|
|
1981
|
+
cached_tokens=context.n_cache_tokens,
|
|
1982
|
+
)
|
|
1983
|
+
return True
|
|
1984
|
+
|
|
1985
|
+
def populate_context_post_run(self, context: AgentContext) -> None:
|
|
1986
|
+
"""Let Harbor ingest Codex usage before adding managed metadata."""
|
|
1987
|
+
|
|
1988
|
+
super().populate_context_post_run(context)
|
|
1989
|
+
fallback_applied = False
|
|
1990
|
+
if not _context_has_usage(context):
|
|
1991
|
+
fallback_applied = self._populate_usage_from_session_token_count(context)
|
|
1992
|
+
|
|
1993
|
+
usage_available = _context_has_usage(context)
|
|
1994
|
+
active_cli_bridge = self._active_loopx_cli_bridge()
|
|
1995
|
+
trace_rows = self._load_loopx_trace_rows()
|
|
1996
|
+
interaction_counters = self._build_loopx_interaction_counters(
|
|
1997
|
+
trace_rows,
|
|
1998
|
+
active_cli_bridge=active_cli_bridge,
|
|
1999
|
+
no_trace_case_result_writeback="not_observed_active_cli_bridge_no_trace",
|
|
2000
|
+
no_trace_counter_trust_level=(
|
|
2001
|
+
"runtime_metadata_active_cli_bridge_no_trace_observed"
|
|
2002
|
+
),
|
|
2003
|
+
)
|
|
2004
|
+
worker_cli_call_total = worker_bridge_cli_call_total_from_interaction_counters(
|
|
2005
|
+
interaction_counters
|
|
2006
|
+
)
|
|
2007
|
+
benchmark_run_json_declared = bool(self.loopx_benchmark_run_json)
|
|
2008
|
+
benchmark_run_payload, benchmark_run_written, benchmark_run_writeback_status = (
|
|
2009
|
+
self._best_effort_loopx_worker_bridge_checkpoint(
|
|
2010
|
+
interrupted=False,
|
|
2011
|
+
interrupt_reason="",
|
|
2012
|
+
checkpoint_kind="post_run",
|
|
2013
|
+
)
|
|
2014
|
+
)
|
|
2015
|
+
|
|
2016
|
+
payload = {
|
|
2017
|
+
**self._loopx_context_metadata,
|
|
2018
|
+
"loopx_interaction_counters": interaction_counters,
|
|
2019
|
+
"loopx_counter_trace_schema_version": LOOPX_COUNTER_TRACE_SCHEMA_VERSION,
|
|
2020
|
+
"loopx_counter_trace_file_loaded": bool(
|
|
2021
|
+
trace_rows and not self.loopx_counter_trace
|
|
2022
|
+
),
|
|
2023
|
+
"loopx_counter_trace_row_count": len(trace_rows),
|
|
2024
|
+
"loopx_benchmark_run_json_declared": (
|
|
2025
|
+
benchmark_run_json_declared if active_cli_bridge else False
|
|
2026
|
+
),
|
|
2027
|
+
"loopx_benchmark_run_schema_version": (
|
|
2028
|
+
self.loopx_benchmark_run_schema_version
|
|
2029
|
+
if active_cli_bridge
|
|
2030
|
+
else None
|
|
2031
|
+
),
|
|
2032
|
+
"loopx_benchmark_run_writeback_contract": (
|
|
2033
|
+
self.loopx_benchmark_run_writeback_contract
|
|
2034
|
+
if active_cli_bridge
|
|
2035
|
+
else None
|
|
2036
|
+
),
|
|
2037
|
+
"loopx_benchmark_run_json_written": benchmark_run_written,
|
|
2038
|
+
"loopx_benchmark_run_writeback_status": benchmark_run_writeback_status,
|
|
2039
|
+
"loopx_worker_cli_call_total": worker_cli_call_total,
|
|
2040
|
+
"loopx_worker_benchmark_run_schema_version": (
|
|
2041
|
+
benchmark_run_payload.get("schema_version")
|
|
2042
|
+
if benchmark_run_written and benchmark_run_payload
|
|
2043
|
+
else None
|
|
2044
|
+
),
|
|
2045
|
+
"context_post_run_ingested": True,
|
|
2046
|
+
"usage_source": CODEX_SESSION_TOKEN_COUNT_USAGE_SOURCE
|
|
2047
|
+
if usage_available
|
|
2048
|
+
else "unavailable",
|
|
2049
|
+
"token_cost_fallback_applied": fallback_applied,
|
|
2050
|
+
"trajectory_present_after_post_run": (
|
|
2051
|
+
self.logs_dir / "trajectory.json"
|
|
2052
|
+
).exists(),
|
|
2053
|
+
"raw_codex_output_recorded": False,
|
|
2054
|
+
"raw_sessions_recorded": False,
|
|
2055
|
+
}
|
|
2056
|
+
_merge_metadata(context, payload)
|