cosmos-platform 1.6.0.dev1__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.
- cosmos_platform-1.6.0.dev1.dist-info/METADATA +150 -0
- cosmos_platform-1.6.0.dev1.dist-info/RECORD +541 -0
- cosmos_platform-1.6.0.dev1.dist-info/WHEEL +5 -0
- cosmos_platform-1.6.0.dev1.dist-info/entry_points.txt +2 -0
- cosmos_platform-1.6.0.dev1.dist-info/licenses/LICENSE +202 -0
- cosmos_platform-1.6.0.dev1.dist-info/top_level.txt +2 -0
- runtime/__init__.py +1 -0
- runtime/candidate/__init__.py +8 -0
- runtime/candidate/admission_gate.py +1776 -0
- runtime/certification/test_certify_opencode_identity.py +71 -0
- runtime/certification/test_certify_w304_windows_silence.py +888 -0
- runtime/certification/test_cosmos15_empirical.py +60 -0
- runtime/certification/test_cosmos_control_center.py +490 -0
- runtime/certification/test_cosmos_dogfood.py +143 -0
- runtime/certification/test_enforcement_census_lc16.py +1112 -0
- runtime/certification/test_eol_byte_stability_p001.py +394 -0
- runtime/certification/test_lc113_adapter_terminal_proofs.py +414 -0
- runtime/certification/test_live_certification_k3.py +622 -0
- runtime/certification/test_mcp_live_c4b.py +1210 -0
- runtime/certification/test_phase9_closeout.py +19 -0
- runtime/certification/test_preservation_census_lc17.py +1039 -0
- runtime/certification/test_self_hosting_cold_reconstruction.py +158 -0
- runtime/certification/test_self_hosting_conformance.py +18 -0
- runtime/certification/test_self_hosting_continuity.py +50 -0
- runtime/certification/test_self_hosting_environment.py +329 -0
- runtime/certification/test_self_hosting_learning.py +56 -0
- runtime/certification/test_self_hosting_two_generation.py +21 -0
- runtime/certification/test_truth_drift_lc18.py +557 -0
- runtime/certification/test_universal_binding_c3.py +770 -0
- runtime/certification/test_w101_attempt2.py +698 -0
- runtime/certification/test_w101_preservation.py +425 -0
- runtime/certification/test_w304_option_a_startup_liveness.py +1093 -0
- runtime/certification/test_w304_wedge_log_flood.py +468 -0
- runtime/certification/test_w304_wedge_recovery.py +258 -0
- runtime/cosmos_runtime/__init__.py +169 -0
- runtime/cosmos_runtime/__main__.py +3 -0
- runtime/cosmos_runtime/actors.py +363 -0
- runtime/cosmos_runtime/adaptive_reasoning.py +242 -0
- runtime/cosmos_runtime/authorization.py +567 -0
- runtime/cosmos_runtime/cli.py +61 -0
- runtime/cosmos_runtime/config.py +21 -0
- runtime/cosmos_runtime/context.py +347 -0
- runtime/cosmos_runtime/continuation.py +548 -0
- runtime/cosmos_runtime/continuity/__init__.py +16 -0
- runtime/cosmos_runtime/continuity/handoff.py +208 -0
- runtime/cosmos_runtime/controller.py +218 -0
- runtime/cosmos_runtime/effects.py +546 -0
- runtime/cosmos_runtime/execution.py +725 -0
- runtime/cosmos_runtime/execution_shim.py +428 -0
- runtime/cosmos_runtime/governance/__init__.py +60 -0
- runtime/cosmos_runtime/governance/completion.py +434 -0
- runtime/cosmos_runtime/governance/gates.py +952 -0
- runtime/cosmos_runtime/governance/scope_types.py +150 -0
- runtime/cosmos_runtime/ids.py +25 -0
- runtime/cosmos_runtime/intake.py +170 -0
- runtime/cosmos_runtime/learning.py +294 -0
- runtime/cosmos_runtime/model.py +240 -0
- runtime/cosmos_runtime/resilience.py +298 -0
- runtime/cosmos_runtime/security/__init__.py +72 -0
- runtime/cosmos_runtime/security/audit.py +139 -0
- runtime/cosmos_runtime/security/consent.py +153 -0
- runtime/cosmos_runtime/security/encryption.py +158 -0
- runtime/cosmos_runtime/security/enterprise_fence.py +169 -0
- runtime/cosmos_runtime/security/injection_detector.py +123 -0
- runtime/cosmos_runtime/security/microphone.py +145 -0
- runtime/cosmos_runtime/security/retention.py +168 -0
- runtime/cosmos_runtime/security/tenant.py +108 -0
- runtime/cosmos_runtime/services.py +187 -0
- runtime/cosmos_runtime/store.py +802 -0
- runtime/cosmos_runtime/telemetry/__init__.py +42 -0
- runtime/cosmos_runtime/telemetry/bus.py +198 -0
- runtime/cosmos_runtime/telemetry/events.py +187 -0
- runtime/cosmos_runtime/telemetry/scrubber.py +119 -0
- runtime/tests/__init__.py +11 -0
- runtime/tests/_pollution_guard.py +311 -0
- runtime/tests/_retrieval_fixtures.py +102 -0
- runtime/tests/_world_isolation.py +138 -0
- runtime/tests/conftest.py +56 -0
- runtime/tests/gate_local_support.py +234 -0
- runtime/tests/test_aaa_pollution_guard.py +218 -0
- runtime/tests/test_actor_routing.py +187 -0
- runtime/tests/test_adapter_family_agent_frameworks_activation.py +883 -0
- runtime/tests/test_adapter_family_cloud_coding_activation.py +1090 -0
- runtime/tests/test_adapter_family_core_cli_activation.py +2039 -0
- runtime/tests/test_adapter_family_emacs_activation.py +769 -0
- runtime/tests/test_adapter_family_ide_rules_activation.py +1016 -0
- runtime/tests/test_adapter_family_jetbrains_eclipse_activation.py +990 -0
- runtime/tests/test_adapter_family_neovim_activation.py +830 -0
- runtime/tests/test_adaptive_reasoning.py +115 -0
- runtime/tests/test_ar4_self_hosting_decoupling.py +49 -0
- runtime/tests/test_assurance_spine_c2.py +411 -0
- runtime/tests/test_authorization_gateway.py +203 -0
- runtime/tests/test_capability_reconciliation_lc14.py +257 -0
- runtime/tests/test_carrier_flow_k3.py +326 -0
- runtime/tests/test_cert_invalidation_k4.py +764 -0
- runtime/tests/test_certification_adversarial_v1.py +882 -0
- runtime/tests/test_claims_matrix_lc15.py +551 -0
- runtime/tests/test_completion.py +306 -0
- runtime/tests/test_context_binding.py +160 -0
- runtime/tests/test_continuation.py +269 -0
- runtime/tests/test_cosmos15_baseline.py +31 -0
- runtime/tests/test_cosmos15_claude_door.py +108 -0
- runtime/tests/test_cosmos15_developer_world.py +194 -0
- runtime/tests/test_cosmos15_observatory.py +286 -0
- runtime/tests/test_cosmos15_operator.py +329 -0
- runtime/tests/test_cosmos_admin.py +221 -0
- runtime/tests/test_cosmos_agent_directory_boundary.py +32 -0
- runtime/tests/test_cosmos_ask.py +119 -0
- runtime/tests/test_cosmos_blocker_gate.py +192 -0
- runtime/tests/test_cosmos_branch_audit.py +227 -0
- runtime/tests/test_cosmos_by_path.py +557 -0
- runtime/tests/test_cosmos_capability_health.py +651 -0
- runtime/tests/test_cosmos_certification.py +98 -0
- runtime/tests/test_cosmos_check_proposal.py +584 -0
- runtime/tests/test_cosmos_check_runner.py +578 -0
- runtime/tests/test_cosmos_check_runner_shard_s1.py +765 -0
- runtime/tests/test_cosmos_cloud_bundle.py +33 -0
- runtime/tests/test_cosmos_cold_clone_binding.py +106 -0
- runtime/tests/test_cosmos_context_authority.py +276 -0
- runtime/tests/test_cosmos_continuation.py +210 -0
- runtime/tests/test_cosmos_continuity.py +147 -0
- runtime/tests/test_cosmos_continuity_demo.py +93 -0
- runtime/tests/test_cosmos_continuity_hook.py +453 -0
- runtime/tests/test_cosmos_controller.py +125 -0
- runtime/tests/test_cosmos_cross_harness_handoff.py +93 -0
- runtime/tests/test_cosmos_current_task_derivation.py +202 -0
- runtime/tests/test_cosmos_decision_guard.py +179 -0
- runtime/tests/test_cosmos_decisions.py +161 -0
- runtime/tests/test_cosmos_defensibility_qualification.py +135 -0
- runtime/tests/test_cosmos_delta.py +512 -0
- runtime/tests/test_cosmos_delta_cli.py +196 -0
- runtime/tests/test_cosmos_dependency_graph.py +94 -0
- runtime/tests/test_cosmos_dependency_graph_scope.py +67 -0
- runtime/tests/test_cosmos_deployment_reconciler.py +213 -0
- runtime/tests/test_cosmos_doctor_command_shadowing.py +61 -0
- runtime/tests/test_cosmos_doorway_validator.py +139 -0
- runtime/tests/test_cosmos_enforce.py +222 -0
- runtime/tests/test_cosmos_events.py +77 -0
- runtime/tests/test_cosmos_evidence.py +122 -0
- runtime/tests/test_cosmos_execution_shim.py +254 -0
- runtime/tests/test_cosmos_feedback.py +97 -0
- runtime/tests/test_cosmos_gate.py +3007 -0
- runtime/tests/test_cosmos_gate_backlog.py +218 -0
- runtime/tests/test_cosmos_gate_categories.py +240 -0
- runtime/tests/test_cosmos_gate_f008.py +386 -0
- runtime/tests/test_cosmos_gate_fast.py +3527 -0
- runtime/tests/test_cosmos_gate_governance.py +196 -0
- runtime/tests/test_cosmos_gate_lessons.py +113 -0
- runtime/tests/test_cosmos_gate_load.py +283 -0
- runtime/tests/test_cosmos_gate_multi.py +357 -0
- runtime/tests/test_cosmos_gate_override.py +114 -0
- runtime/tests/test_cosmos_gate_profile.py +271 -0
- runtime/tests/test_cosmos_gate_recheck.py +134 -0
- runtime/tests/test_cosmos_gate_runtime.py +304 -0
- runtime/tests/test_cosmos_gate_selfcheck.py +27 -0
- runtime/tests/test_cosmos_gate_skip.py +95 -0
- runtime/tests/test_cosmos_git_hooks.py +117 -0
- runtime/tests/test_cosmos_guard.py +938 -0
- runtime/tests/test_cosmos_harness_doors.py +50 -0
- runtime/tests/test_cosmos_hygiene.py +76 -0
- runtime/tests/test_cosmos_hypothesis.py +106 -0
- runtime/tests/test_cosmos_index_hot_journal.py +108 -0
- runtime/tests/test_cosmos_landing_board.py +228 -0
- runtime/tests/test_cosmos_learn.py +92 -0
- runtime/tests/test_cosmos_levels_of_done.py +67 -0
- runtime/tests/test_cosmos_lineage.py +157 -0
- runtime/tests/test_cosmos_mcp_binding.py +182 -0
- runtime/tests/test_cosmos_mcp_governed_tools.py +185 -0
- runtime/tests/test_cosmos_mcp_registration.py +430 -0
- runtime/tests/test_cosmos_memory_maintenance.py +81 -0
- runtime/tests/test_cosmos_modality_registry.py +52 -0
- runtime/tests/test_cosmos_narrative.py +189 -0
- runtime/tests/test_cosmos_navigator_product_path.py +56 -0
- runtime/tests/test_cosmos_next.py +669 -0
- runtime/tests/test_cosmos_no_raw_process_start.py +92 -0
- runtime/tests/test_cosmos_objective_convergence.py +86 -0
- runtime/tests/test_cosmos_obligation_lc03.py +745 -0
- runtime/tests/test_cosmos_obligations.py +302 -0
- runtime/tests/test_cosmos_observe.py +100 -0
- runtime/tests/test_cosmos_onboarding.py +224 -0
- runtime/tests/test_cosmos_override_gate.py +288 -0
- runtime/tests/test_cosmos_packaging_billing_gate.py +396 -0
- runtime/tests/test_cosmos_pilot.py +165 -0
- runtime/tests/test_cosmos_popup_check.py +75 -0
- runtime/tests/test_cosmos_proc_owned_tree.py +249 -0
- runtime/tests/test_cosmos_project_adapters.py +158 -0
- runtime/tests/test_cosmos_push.py +178 -0
- runtime/tests/test_cosmos_qualification.py +94 -0
- runtime/tests/test_cosmos_remediation.py +67 -0
- runtime/tests/test_cosmos_report.py +99 -0
- runtime/tests/test_cosmos_retrieval.py +512 -0
- runtime/tests/test_cosmos_retrieval_cli_mcp.py +198 -0
- runtime/tests/test_cosmos_retrieval_model_fetch.py +40 -0
- runtime/tests/test_cosmos_safety.py +528 -0
- runtime/tests/test_cosmos_security_package.py +417 -0
- runtime/tests/test_cosmos_security_qualification.py +59 -0
- runtime/tests/test_cosmos_self_repair.py +504 -0
- runtime/tests/test_cosmos_serving.py +153 -0
- runtime/tests/test_cosmos_session_lifecycle.py +181 -0
- runtime/tests/test_cosmos_session_start.py +493 -0
- runtime/tests/test_cosmos_settings_hooks.py +36 -0
- runtime/tests/test_cosmos_speed_limits.py +36 -0
- runtime/tests/test_cosmos_staging_qualification.py +117 -0
- runtime/tests/test_cosmos_stop_guard.py +84 -0
- runtime/tests/test_cosmos_studio.py +1102 -0
- runtime/tests/test_cosmos_substrate_liveness.py +111 -0
- runtime/tests/test_cosmos_supply_chain_gate.py +238 -0
- runtime/tests/test_cosmos_synthetic_pilot.py +46 -0
- runtime/tests/test_cosmos_telemetry.py +65 -0
- runtime/tests/test_cosmos_telemetry_bus.py +157 -0
- runtime/tests/test_cosmos_telemetry_scrubber.py +124 -0
- runtime/tests/test_cosmos_tracker_render.py +95 -0
- runtime/tests/test_cosmos_trigger_records.py +198 -0
- runtime/tests/test_cosmos_tripartite_delta.py +154 -0
- runtime/tests/test_cosmos_tripartite_events.py +103 -0
- runtime/tests/test_cosmos_trust_readiness.py +375 -0
- runtime/tests/test_cosmos_vault.py +3524 -0
- runtime/tests/test_cosmos_vault_entry_points.py +920 -0
- runtime/tests/test_cosmos_vault_worker.py +1450 -0
- runtime/tests/test_cosmos_visibility_policy.py +187 -0
- runtime/tests/test_cosmos_wake.py +43 -0
- runtime/tests/test_cosmos_watchdog.py +1318 -0
- runtime/tests/test_cosmos_world_refresh_and_capture.py +711 -0
- runtime/tests/test_cosmos_wrong_direction.py +214 -0
- runtime/tests/test_cosmos_zero_step.py +245 -0
- runtime/tests/test_daemon_supervisor_c5b.py +845 -0
- runtime/tests/test_enforcement_live_c4.py +485 -0
- runtime/tests/test_execution_loop.py +216 -0
- runtime/tests/test_foundation.py +145 -0
- runtime/tests/test_governance_gates.py +327 -0
- runtime/tests/test_intake.py +107 -0
- runtime/tests/test_invalidationscan_k4.py +776 -0
- runtime/tests/test_lc112_live_attestation_commission.py +292 -0
- runtime/tests/test_lc133_lp2_entry_points.py +268 -0
- runtime/tests/test_lc1_baseline_lc19.py +702 -0
- runtime/tests/test_levels_of_done_k1.py +474 -0
- runtime/tests/test_live_attestation_k2.py +521 -0
- runtime/tests/test_live_attestation_k2_regressions.py +442 -0
- runtime/tests/test_live_certification_k3_regressions.py +623 -0
- runtime/tests/test_lp7_studio_trigger.py +191 -0
- runtime/tests/test_master_plan_revision_identity.py +123 -0
- runtime/tests/test_multi_harness_acceptance.py +292 -0
- runtime/tests/test_multi_harness_stress.py +188 -0
- runtime/tests/test_objective_live_c1.py +437 -0
- runtime/tests/test_obligation_reconciliation_lc13.py +351 -0
- runtime/tests/test_observation_projection.py +156 -0
- runtime/tests/test_observation_wiring.py +100 -0
- runtime/tests/test_one_active_wave_lc06.py +629 -0
- runtime/tests/test_operational_sandbox_harness.py +111 -0
- runtime/tests/test_p002_canonical_engine.py +275 -0
- runtime/tests/test_p003_watcher_failure_attribution.py +933 -0
- runtime/tests/test_phase8_closeout.py +89 -0
- runtime/tests/test_phase8_company_environment.py +84 -0
- runtime/tests/test_phase8_company_proof.py +278 -0
- runtime/tests/test_phase8_cross_environment_audit.py +89 -0
- runtime/tests/test_phase8_developer_environment.py +59 -0
- runtime/tests/test_phase8_developer_proof.py +204 -0
- runtime/tests/test_phase8_harness.py +66 -0
- runtime/tests/test_phase8_personal_environment.py +62 -0
- runtime/tests/test_phase8_personal_proof.py +105 -0
- runtime/tests/test_phase8_protocol.py +180 -0
- runtime/tests/test_plan_before_code_lc04.py +830 -0
- runtime/tests/test_plan_census_lc12.py +243 -0
- runtime/tests/test_repo_census_lc11.py +230 -0
- runtime/tests/test_resilience.py +182 -0
- runtime/tests/test_retrieval_live_c5.py +270 -0
- runtime/tests/test_run_monitor_s2.py +587 -0
- runtime/tests/test_runtime_conformance.py +389 -0
- runtime/tests/test_sandbox_adapters.py +238 -0
- runtime/tests/test_scale_acceptance.py +114 -0
- runtime/tests/test_scope_freeze_lc05.py +638 -0
- runtime/tests/test_self_hosting_first_change.py +69 -0
- runtime/tests/test_self_hosting_projection.py +145 -0
- runtime/tests/test_self_hosting_protocol.py +87 -0
- runtime/tests/test_siem_integration_harness.py +98 -0
- runtime/tests/test_sign_release_archive.py +141 -0
- runtime/tests/test_store_concurrency.py +118 -0
- runtime/tests/test_studio_broker_integration.py +147 -0
- runtime/tests/test_tiers_doc.py +54 -0
- runtime/tests/test_trigger_firing_c1.py +342 -0
- runtime/tests/test_verify_tripartite_observability.py +120 -0
- runtime/tests/test_w102_branch_audit_equivalence.py +334 -0
- runtime/tests/test_w102_git_timeout_hang.py +233 -0
- runtime/tests/test_w103_identity.py +378 -0
- runtime/tests/test_w103_real_harness_identity.py +159 -0
- runtime/tests/test_w103_review_correction.py +224 -0
- runtime/tests/test_w103_round2_consumption.py +304 -0
- runtime/tests/test_w304_silent_background.py +713 -0
- runtime/tests/test_wave_report_lc07.py +332 -0
- tools/__init__.py +5 -0
- tools/adapter_families/agent_frameworks.py +1418 -0
- tools/adapter_families/cloud_coding.py +875 -0
- tools/adapter_families/core_cli.py +2519 -0
- tools/adapter_families/emacs.py +1247 -0
- tools/adapter_families/ide_rules.py +1105 -0
- tools/adapter_families/jetbrains_eclipse.py +1381 -0
- tools/adapter_families/neovim.py +995 -0
- tools/build_cosmos15_release_archive.py +110 -0
- tools/catalogs/model-modalities.json +84 -0
- tools/catalogs/ui-ux-catalog.json +173 -0
- tools/control_center/app.js +78 -0
- tools/control_center/index.html +35 -0
- tools/control_center/styles.css +4 -0
- tools/cosmos.py +1018 -0
- tools/cosmos15_operator.py +980 -0
- tools/cosmos15_world_recovery.py +292 -0
- tools/cosmos_adapter_health.py +311 -0
- tools/cosmos_ask.py +102 -0
- tools/cosmos_attach.py +237 -0
- tools/cosmos_background.py +258 -0
- tools/cosmos_bind.py +764 -0
- tools/cosmos_binding.py +130 -0
- tools/cosmos_blocker_gate.py +285 -0
- tools/cosmos_branch_audit.py +315 -0
- tools/cosmos_capability_health.py +4202 -0
- tools/cosmos_capability_reconciliation.py +419 -0
- tools/cosmos_capture_hook.py +644 -0
- tools/cosmos_cert_invalidation.py +1673 -0
- tools/cosmos_certification.py +506 -0
- tools/cosmos_check_proposal.py +483 -0
- tools/cosmos_check_runner.py +2480 -0
- tools/cosmos_claims_matrix.py +851 -0
- tools/cosmos_claude_door.py +268 -0
- tools/cosmos_cloud_bundle.py +73 -0
- tools/cosmos_context_authority.py +515 -0
- tools/cosmos_continuation.py +315 -0
- tools/cosmos_continuity_demo.py +180 -0
- tools/cosmos_continuity_wrapper.py +194 -0
- tools/cosmos_control_center.py +476 -0
- tools/cosmos_curator.py +175 -0
- tools/cosmos_daemon_supervisor.py +3082 -0
- tools/cosmos_decision_guard.py +206 -0
- tools/cosmos_decision_rank.py +103 -0
- tools/cosmos_decisions.py +343 -0
- tools/cosmos_defensibility_qualification.py +322 -0
- tools/cosmos_delta.py +887 -0
- tools/cosmos_dependency_graph.py +235 -0
- tools/cosmos_deployment_reconciler.py +393 -0
- tools/cosmos_design_dna.py +377 -0
- tools/cosmos_developer_world.py +1233 -0
- tools/cosmos_doctor.py +427 -0
- tools/cosmos_door_common.py +16 -0
- tools/cosmos_door_helpers.py +54 -0
- tools/cosmos_doorway_validator.py +152 -0
- tools/cosmos_enforce.py +527 -0
- tools/cosmos_enforcement_census.py +2657 -0
- tools/cosmos_eval.py +310 -0
- tools/cosmos_events.py +123 -0
- tools/cosmos_evidence.py +135 -0
- tools/cosmos_feedback.py +252 -0
- tools/cosmos_forge_adapters.py +190 -0
- tools/cosmos_forge_protection.py +154 -0
- tools/cosmos_fs_watcher.py +1378 -0
- tools/cosmos_gate.py +3172 -0
- tools/cosmos_gate_backlog.py +294 -0
- tools/cosmos_gate_carry.py +122 -0
- tools/cosmos_gate_categories.py +159 -0
- tools/cosmos_gate_closure.py +56 -0
- tools/cosmos_gate_fast.py +2592 -0
- tools/cosmos_gate_governance.py +282 -0
- tools/cosmos_gate_holdout.py +704 -0
- tools/cosmos_gate_linux.py +203 -0
- tools/cosmos_gate_load.py +205 -0
- tools/cosmos_gate_override.py +82 -0
- tools/cosmos_gate_profile.py +169 -0
- tools/cosmos_gate_protect.py +79 -0
- tools/cosmos_gate_replacements.py +66 -0
- tools/cosmos_gate_runtime.py +123 -0
- tools/cosmos_gate_scope.py +110 -0
- tools/cosmos_gate_selfcheck.py +79 -0
- tools/cosmos_gate_service.py +591 -0
- tools/cosmos_gate_union.py +108 -0
- tools/cosmos_git_hooks.py +59 -0
- tools/cosmos_githooks.py +94 -0
- tools/cosmos_guard.py +1887 -0
- tools/cosmos_harness_doors.py +350 -0
- tools/cosmos_home_guard.py +199 -0
- tools/cosmos_hygiene.py +251 -0
- tools/cosmos_hypothesis.py +124 -0
- tools/cosmos_identity.py +295 -0
- tools/cosmos_invariants.py +212 -0
- tools/cosmos_landing_board.py +394 -0
- tools/cosmos_launch.py +432 -0
- tools/cosmos_launcher.py +177 -0
- tools/cosmos_lc1_baseline.py +776 -0
- tools/cosmos_learn.py +319 -0
- tools/cosmos_levels_of_done.py +740 -0
- tools/cosmos_lineage.py +201 -0
- tools/cosmos_live_attestation.py +1559 -0
- tools/cosmos_mcp_registration.py +625 -0
- tools/cosmos_mcp_server.py +2253 -0
- tools/cosmos_memory.py +273 -0
- tools/cosmos_memory_check.py +97 -0
- tools/cosmos_modality_registry.py +113 -0
- tools/cosmos_narrative.py +225 -0
- tools/cosmos_next.py +659 -0
- tools/cosmos_objective_convergence.py +167 -0
- tools/cosmos_obligations.py +2809 -0
- tools/cosmos_observation_projection.py +144 -0
- tools/cosmos_observe.py +353 -0
- tools/cosmos_opencode_push.js +164 -0
- tools/cosmos_overlay_injector.py +44 -0
- tools/cosmos_override_gate.py +550 -0
- tools/cosmos_packaging_billing_gate.py +314 -0
- tools/cosmos_packet.py +973 -0
- tools/cosmos_pilot.py +731 -0
- tools/cosmos_plan_census.py +634 -0
- tools/cosmos_popup_check.py +260 -0
- tools/cosmos_premise.py +327 -0
- tools/cosmos_preservation_census.py +2185 -0
- tools/cosmos_proc.py +639 -0
- tools/cosmos_project_adapters.py +2773 -0
- tools/cosmos_push.py +138 -0
- tools/cosmos_qualification.py +291 -0
- tools/cosmos_reachability.py +345 -0
- tools/cosmos_reconciliation.py +451 -0
- tools/cosmos_refresh_adapters.py +80 -0
- tools/cosmos_remediation.py +166 -0
- tools/cosmos_repo_census.py +640 -0
- tools/cosmos_repo_finder.py +217 -0
- tools/cosmos_report.py +134 -0
- tools/cosmos_retrieval/__init__.py +41 -0
- tools/cosmos_retrieval/__main__.py +4 -0
- tools/cosmos_retrieval/activation.py +564 -0
- tools/cosmos_retrieval/cli.py +274 -0
- tools/cosmos_retrieval/embedders.py +214 -0
- tools/cosmos_retrieval/index.py +884 -0
- tools/cosmos_retrieval/model_fetch.py +122 -0
- tools/cosmos_retrieval/text.py +243 -0
- tools/cosmos_retrieval/vectors.py +101 -0
- tools/cosmos_rollback.py +453 -0
- tools/cosmos_run_monitor.py +1198 -0
- tools/cosmos_safety.py +350 -0
- tools/cosmos_scorecard.py +466 -0
- tools/cosmos_security_qualification.py +202 -0
- tools/cosmos_self_repair.py +192 -0
- tools/cosmos_serving.py +339 -0
- tools/cosmos_session_brief.py +302 -0
- tools/cosmos_session_lifecycle.py +389 -0
- tools/cosmos_session_start.py +1894 -0
- tools/cosmos_setup.py +585 -0
- tools/cosmos_staging_qualification.py +252 -0
- tools/cosmos_stop_guard.py +111 -0
- tools/cosmos_studio_app.py +2225 -0
- tools/cosmos_supply_chain_gate.py +454 -0
- tools/cosmos_synthetic_pilot.py +215 -0
- tools/cosmos_telemetry.py +153 -0
- tools/cosmos_tracker_render.py +196 -0
- tools/cosmos_trust_readiness.py +607 -0
- tools/cosmos_truth_drift.py +1573 -0
- tools/cosmos_vault.py +2023 -0
- tools/cosmos_vault_acl.py +715 -0
- tools/cosmos_vault_bundle.py +438 -0
- tools/cosmos_vault_install.py +471 -0
- tools/cosmos_vault_service.py +345 -0
- tools/cosmos_vault_worker.py +745 -0
- tools/cosmos_visibility_policy.py +134 -0
- tools/cosmos_wake.py +262 -0
- tools/cosmos_watchdog.py +1775 -0
- tools/cosmos_watchdog_timing.py +100 -0
- tools/cosmos_wave_report.py +357 -0
- tools/cosmos_wrong_direction.py +217 -0
- tools/evaluate_assurance_risk.py +302 -0
- tools/generate_execution_stack_conformance_fixtures.py +122 -0
- tools/generate_execution_stack_envelope_fixtures.py +122 -0
- tools/generate_model_route_receipt_fixtures.py +320 -0
- tools/observatory/README.md +64 -0
- tools/observatory/app.js +486 -0
- tools/observatory/index.html +82 -0
- tools/observatory/launcher.css +249 -0
- tools/observatory/launcher.html +80 -0
- tools/observatory/launcher.js +173 -0
- tools/observatory/styles.css +83 -0
- tools/operational_sandbox_harness.py +481 -0
- tools/owner_requeue.py +402 -0
- tools/reference_authorization.py +427 -0
- tools/reference_cold_reconstruction.py +264 -0
- tools/reference_context_binder.py +570 -0
- tools/reference_cosmos15_empirical.py +208 -0
- tools/reference_dogfood_runner.py +166 -0
- tools/reference_environment_audit.py +332 -0
- tools/reference_environment_harness.py +764 -0
- tools/reference_environment_proof.py +206 -0
- tools/reference_first_self_change.py +342 -0
- tools/reference_generation_a_continuation.py +111 -0
- tools/reference_generation_b_continuation.py +102 -0
- tools/reference_knowledge_lifecycle.py +318 -0
- tools/reference_maintenance.py +399 -0
- tools/reference_observatory.py +848 -0
- tools/reference_phase8_closeout.py +249 -0
- tools/reference_phase9_closeout.py +138 -0
- tools/reference_repository_projection.py +689 -0
- tools/reference_self_hosting.py +245 -0
- tools/reference_self_hosting_conformance.py +118 -0
- tools/reference_self_hosting_continuity.py +227 -0
- tools/reference_self_hosting_environment.py +411 -0
- tools/reference_self_learning.py +284 -0
- tools/run_execution_stack_conformance.py +195 -0
- tools/schemas/cosmos-certification.schema.json +65 -0
- tools/schemas/cosmos-record.schema.json +2918 -0
- tools/schemas/enterprise-audit-export.schema.json +255 -0
- tools/schemas/enterprise-durability-recovery.schema.json +282 -0
- tools/schemas/enterprise-execution-sandbox.schema.json +241 -0
- tools/schemas/enterprise-identity-policy.schema.json +222 -0
- tools/schemas/enterprise-secrets.schema.json +243 -0
- tools/schemas/environment-pack.schema.json +184 -0
- tools/schemas/environment-proof-case.schema.json +131 -0
- tools/schemas/execution-stack-conformance.schema.json +132 -0
- tools/schemas/execution-stack-envelope.schema.json +161 -0
- tools/schemas/model-modality-profile.schema.json +66 -0
- tools/schemas/model-route-receipt.schema.json +71 -0
- tools/schemas/relation-type.schema.json +76 -0
- tools/schemas/release-manifest.schema.json +58 -0
- tools/schemas/self-hosting-contract.schema.json +143 -0
- tools/siem_integration_harness.py +413 -0
- tools/sign_release_archive.py +357 -0
- tools/spec/reveal-register.json +65 -0
- tools/spec/reveal-register.schema.json +41 -0
- tools/stitch_design_bridge.py +593 -0
- tools/studio/byom_router.js +101 -0
- tools/studio/ide.html +109 -0
- tools/studio/ide.js +62 -0
- tools/studio/index.html +23 -0
- tools/studio/modality_guard.js +101 -0
- tools/studio/observatory_dock.js +60 -0
- tools/studio/studio.css +489 -0
- tools/studio/studio.js +50 -0
- tools/studio/studio_concentric_live.png +0 -0
- tools/studio/studio_cosmos_canvas.png +0 -0
- tools/studio/studio_hero_live.png +0 -0
- tools/studio/studio_live.png +0 -0
- tools/studio/studio_preview.png +0 -0
- tools/studio/studio_refined_platform.png +0 -0
- tools/studio/subatomic_sidecar.js +57 -0
- tools/validate_environment_proof.py +39 -0
- tools/validate_execution_stack_envelopes.py +157 -0
- tools/validate_model_route_receipts.py +183 -0
- tools/validate_ontology.py +121 -0
- tools/verify_cosmos15_baseline.py +104 -0
- tools/verify_cosmos15_release_archive.py +225 -0
- tools/verify_tripartite_observability.py +136 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import tempfile
|
|
4
|
+
import unittest
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
|
|
7
|
+
from runtime.cosmos_runtime import (
|
|
8
|
+
ActionRequest,
|
|
9
|
+
ActorRequest,
|
|
10
|
+
ActorResponse,
|
|
11
|
+
AdapterRegistry,
|
|
12
|
+
AdapterResult,
|
|
13
|
+
AuthorizationGateway,
|
|
14
|
+
CompletionDecision,
|
|
15
|
+
DeterministicActorAdapter,
|
|
16
|
+
EvidenceRecord,
|
|
17
|
+
ExecutionEngine,
|
|
18
|
+
ExecutionFailure,
|
|
19
|
+
ModelProfile,
|
|
20
|
+
ObjectiveRequest,
|
|
21
|
+
RuntimeConfig,
|
|
22
|
+
build_services,
|
|
23
|
+
)
|
|
24
|
+
from runtime.cosmos_runtime.model import ExecutionState, TaskState
|
|
25
|
+
from runtime.cosmos_runtime.ids import new_runtime_id
|
|
26
|
+
from runtime.cosmos_runtime.model import utc_now
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
ACTOR = "cosmos:actor:exec"
|
|
30
|
+
RESOURCE = "tool:echo"
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
class ExecutionLoopTests(unittest.TestCase):
|
|
34
|
+
def setUp(self):
|
|
35
|
+
self.tempdir = tempfile.TemporaryDirectory()
|
|
36
|
+
self.services = build_services(RuntimeConfig(
|
|
37
|
+
database_path=Path(self.tempdir.name) / "runtime.sqlite3",
|
|
38
|
+
environment_ref="cosmos:test",
|
|
39
|
+
))
|
|
40
|
+
self.intake = self.services.intake_objective(ObjectiveRequest(
|
|
41
|
+
objective="execute safely",
|
|
42
|
+
requester_ref=ACTOR,
|
|
43
|
+
execution_actor_ref=ACTOR,
|
|
44
|
+
environment_ref="cosmos:test",
|
|
45
|
+
idempotency_key="execution-loop-test",
|
|
46
|
+
))
|
|
47
|
+
episode = self.services.store.get_episode(self.intake.episode_id)
|
|
48
|
+
self.services.store.transition_episode(episode.episode_id, ExecutionState.PREPARING, expected_state=ExecutionState.CREATED)
|
|
49
|
+
self.services.store.transition_episode(episode.episode_id, ExecutionState.READY, expected_state=ExecutionState.PREPARING)
|
|
50
|
+
self.state = {
|
|
51
|
+
"capabilities": [{
|
|
52
|
+
"capability_id": "cap:tool",
|
|
53
|
+
"grantee_refs": [ACTOR],
|
|
54
|
+
"action": "tool.invoke",
|
|
55
|
+
"decision": "allow",
|
|
56
|
+
"resources": [RESOURCE],
|
|
57
|
+
"constraints": {},
|
|
58
|
+
"task_ref": self.intake.task.task_ref,
|
|
59
|
+
}],
|
|
60
|
+
"approvals": [],
|
|
61
|
+
"delegations": [],
|
|
62
|
+
}
|
|
63
|
+
self.authorization = AuthorizationGateway(self.services, lambda _: self.state)
|
|
64
|
+
|
|
65
|
+
def tearDown(self):
|
|
66
|
+
self.tempdir.cleanup()
|
|
67
|
+
|
|
68
|
+
def actor(self, responses):
|
|
69
|
+
return DeterministicActorAdapter(
|
|
70
|
+
ModelProfile(adapter_id="test", provider="test", model="test"),
|
|
71
|
+
responses=responses,
|
|
72
|
+
)
|
|
73
|
+
|
|
74
|
+
def verified_evidence(self, task, effects, evidence, artifacts):
|
|
75
|
+
return [EvidenceRecord(
|
|
76
|
+
evidence_ref=new_runtime_id("verify"),
|
|
77
|
+
episode_id=self.intake.episode_id,
|
|
78
|
+
evidence_kind="verification",
|
|
79
|
+
source_ref=task.task_ref,
|
|
80
|
+
data={"verified_effects": [x.performed_effect_id for x in effects]},
|
|
81
|
+
verified=True,
|
|
82
|
+
recorded_at=utc_now(),
|
|
83
|
+
)]
|
|
84
|
+
|
|
85
|
+
def completion(self, task, effects, evidence, artifacts):
|
|
86
|
+
refs = tuple(e.evidence_ref for e in evidence if e.evidence_kind == "verification" and e.verified)
|
|
87
|
+
return CompletionDecision(bool(refs), "independent verification present" if refs else "verification missing", refs)
|
|
88
|
+
|
|
89
|
+
def test_allowed_effect_reconciles_and_verified_task_completes(self):
|
|
90
|
+
actor = self.actor([
|
|
91
|
+
ActorResponse(action_requests=(ActionRequest("r1", "tool.invoke", RESOURCE, {"value": 3}, "echo"),), finish_reason="tool_calls"),
|
|
92
|
+
ActorResponse(text="done", finish_reason="stop"),
|
|
93
|
+
])
|
|
94
|
+
registry = AdapterRegistry()
|
|
95
|
+
registry.register("tool.invoke", lambda authorized: AdapterResult(
|
|
96
|
+
actual_action="tool.invoke",
|
|
97
|
+
actual_resource_ref=RESOURCE,
|
|
98
|
+
actual_parameters={"value": 3},
|
|
99
|
+
output={"value": 3},
|
|
100
|
+
evidence=({"kind": "tool_receipt", "verified": True},),
|
|
101
|
+
))
|
|
102
|
+
engine = ExecutionEngine(
|
|
103
|
+
services=self.services,
|
|
104
|
+
actor=actor,
|
|
105
|
+
authorization=self.authorization,
|
|
106
|
+
adapters=registry,
|
|
107
|
+
completion_verifier=self.completion,
|
|
108
|
+
verification_hook=self.verified_evidence,
|
|
109
|
+
)
|
|
110
|
+
summary = engine.run(
|
|
111
|
+
episode_id=self.intake.episode_id,
|
|
112
|
+
actor_request=ActorRequest(objective="execute safely"),
|
|
113
|
+
)
|
|
114
|
+
self.assertTrue(summary.verified_complete)
|
|
115
|
+
episode = self.services.store.get_episode(self.intake.episode_id)
|
|
116
|
+
task = self.services.store.get_task(self.intake.task.task_ref)
|
|
117
|
+
self.assertEqual(episode.state, ExecutionState.COMPLETED)
|
|
118
|
+
self.assertEqual(task.task_state, TaskState.COMPLETED)
|
|
119
|
+
self.assertTrue(task.completion_evidence_refs)
|
|
120
|
+
self.assertTrue(any(e.event_type == "runtime.effect.performed" for e in self.services.store.list_events(self.intake.episode_id)))
|
|
121
|
+
|
|
122
|
+
def test_model_stop_claim_without_independent_verifier_never_completes(self):
|
|
123
|
+
engine = ExecutionEngine(
|
|
124
|
+
services=self.services,
|
|
125
|
+
actor=self.actor([ActorResponse(text="I am done", finish_reason="stop")]),
|
|
126
|
+
authorization=self.authorization,
|
|
127
|
+
adapters=AdapterRegistry(),
|
|
128
|
+
)
|
|
129
|
+
summary = engine.run(
|
|
130
|
+
episode_id=self.intake.episode_id,
|
|
131
|
+
actor_request=ActorRequest(objective="execute safely"),
|
|
132
|
+
)
|
|
133
|
+
self.assertFalse(summary.verified_complete)
|
|
134
|
+
self.assertEqual(self.services.store.get_episode(self.intake.episode_id).state, ExecutionState.SUSPENDED)
|
|
135
|
+
self.assertEqual(self.services.store.get_task(self.intake.task.task_ref).task_state, TaskState.BLOCKED)
|
|
136
|
+
|
|
137
|
+
def test_performed_effect_mismatch_fails_episode_and_is_reconstructable(self):
|
|
138
|
+
actor = self.actor([
|
|
139
|
+
ActorResponse(action_requests=(ActionRequest("r1", "tool.invoke", RESOURCE, {}, "echo"),), finish_reason="tool_calls"),
|
|
140
|
+
])
|
|
141
|
+
registry = AdapterRegistry()
|
|
142
|
+
registry.register("tool.invoke", lambda authorized: AdapterResult(
|
|
143
|
+
actual_action="tool.invoke",
|
|
144
|
+
actual_resource_ref="tool:other",
|
|
145
|
+
output="bad",
|
|
146
|
+
))
|
|
147
|
+
engine = ExecutionEngine(
|
|
148
|
+
services=self.services,
|
|
149
|
+
actor=actor,
|
|
150
|
+
authorization=self.authorization,
|
|
151
|
+
adapters=registry,
|
|
152
|
+
)
|
|
153
|
+
with self.assertRaises(ExecutionFailure):
|
|
154
|
+
engine.run(episode_id=self.intake.episode_id, actor_request=ActorRequest(objective="x"))
|
|
155
|
+
episode = self.services.store.get_episode(self.intake.episode_id)
|
|
156
|
+
self.assertEqual(episode.state, ExecutionState.FAILED)
|
|
157
|
+
self.assertEqual(episode.last_error.code, "runtime.execution_failed")
|
|
158
|
+
self.assertTrue(any(e.event_type == "runtime.execution.failed" for e in self.services.store.list_events(self.intake.episode_id)))
|
|
159
|
+
|
|
160
|
+
def test_high_impact_effect_without_post_effect_evidence_cannot_complete(self):
|
|
161
|
+
self.state["capabilities"][0]["high_impact"] = True
|
|
162
|
+
self.state["approvals"].append({
|
|
163
|
+
"approval_id": "approval:tool-high-impact",
|
|
164
|
+
"state": "active",
|
|
165
|
+
"beneficiary_actor_ref": ACTOR,
|
|
166
|
+
"action": "tool.invoke",
|
|
167
|
+
"resources": [RESOURCE],
|
|
168
|
+
"constraints": {},
|
|
169
|
+
"task_ref": self.intake.task.task_ref,
|
|
170
|
+
})
|
|
171
|
+
actor = self.actor([
|
|
172
|
+
ActorResponse(action_requests=(ActionRequest("r1", "tool.invoke", RESOURCE, {}, "echo"),), finish_reason="tool_calls"),
|
|
173
|
+
ActorResponse(text="done", finish_reason="stop"),
|
|
174
|
+
])
|
|
175
|
+
registry = AdapterRegistry()
|
|
176
|
+
registry.register("tool.invoke", lambda authorized: AdapterResult(
|
|
177
|
+
actual_action="tool.invoke",
|
|
178
|
+
actual_resource_ref=RESOURCE,
|
|
179
|
+
output="changed",
|
|
180
|
+
evidence=(),
|
|
181
|
+
))
|
|
182
|
+
engine = ExecutionEngine(
|
|
183
|
+
services=self.services,
|
|
184
|
+
actor=actor,
|
|
185
|
+
authorization=self.authorization,
|
|
186
|
+
adapters=registry,
|
|
187
|
+
completion_verifier=lambda *args: CompletionDecision(True, "verifier says yes"),
|
|
188
|
+
verification_hook=self.verified_evidence,
|
|
189
|
+
)
|
|
190
|
+
summary = engine.run(episode_id=self.intake.episode_id, actor_request=ActorRequest(objective="x"))
|
|
191
|
+
self.assertFalse(summary.verified_complete)
|
|
192
|
+
self.assertEqual(self.services.store.get_episode(self.intake.episode_id).state, ExecutionState.SUSPENDED)
|
|
193
|
+
|
|
194
|
+
def test_adapter_failure_leaves_durable_failed_state(self):
|
|
195
|
+
actor = self.actor([
|
|
196
|
+
ActorResponse(action_requests=(ActionRequest("r1", "tool.invoke", RESOURCE, {}, "echo"),), finish_reason="tool_calls"),
|
|
197
|
+
])
|
|
198
|
+
registry = AdapterRegistry()
|
|
199
|
+
def fail(_):
|
|
200
|
+
raise RuntimeError("adapter exploded")
|
|
201
|
+
registry.register("tool.invoke", fail)
|
|
202
|
+
engine = ExecutionEngine(
|
|
203
|
+
services=self.services,
|
|
204
|
+
actor=actor,
|
|
205
|
+
authorization=self.authorization,
|
|
206
|
+
adapters=registry,
|
|
207
|
+
)
|
|
208
|
+
with self.assertRaises(RuntimeError):
|
|
209
|
+
engine.run(episode_id=self.intake.episode_id, actor_request=ActorRequest(objective="x"))
|
|
210
|
+
episode = self.services.store.get_episode(self.intake.episode_id)
|
|
211
|
+
self.assertEqual(episode.state, ExecutionState.FAILED)
|
|
212
|
+
self.assertIn("adapter exploded", episode.last_error.message)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
if __name__ == "__main__":
|
|
216
|
+
unittest.main()
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from tools import cosmos_proc as subprocess
|
|
5
|
+
import sys
|
|
6
|
+
import tempfile
|
|
7
|
+
import unittest
|
|
8
|
+
from pathlib import Path
|
|
9
|
+
|
|
10
|
+
from runtime.cosmos_runtime.config import RuntimeConfig
|
|
11
|
+
from runtime.cosmos_runtime.model import ExecutionState, RuntimeErrorInfo, RuntimeEvent, utc_now
|
|
12
|
+
from runtime.cosmos_runtime.services import build_services
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class RuntimeFoundationTests(unittest.TestCase):
|
|
16
|
+
def setUp(self) -> None:
|
|
17
|
+
self.tempdir = tempfile.TemporaryDirectory()
|
|
18
|
+
self.db = Path(self.tempdir.name) / "runtime.sqlite3"
|
|
19
|
+
self.services = build_services(RuntimeConfig(database_path=self.db, environment_ref="cosmos:test"))
|
|
20
|
+
|
|
21
|
+
def tearDown(self) -> None:
|
|
22
|
+
self.tempdir.cleanup()
|
|
23
|
+
|
|
24
|
+
def _drive_to_running(self):
|
|
25
|
+
ep = self.services.new_episode()
|
|
26
|
+
for target in (ExecutionState.PREPARING, ExecutionState.READY, ExecutionState.RUNNING):
|
|
27
|
+
self.services.store.transition_episode(ep.episode_id, target)
|
|
28
|
+
return ep
|
|
29
|
+
|
|
30
|
+
def test_invariant1_cannot_complete_without_result_observation(self) -> None:
|
|
31
|
+
# LOOP-1 / DEC-2026-0920-07: no episode reaches COMPLETED without a
|
|
32
|
+
# recorded result observation.
|
|
33
|
+
from runtime.cosmos_runtime.store import ResultObservationRequired
|
|
34
|
+
|
|
35
|
+
ep = self._drive_to_running()
|
|
36
|
+
with self.assertRaises(ResultObservationRequired):
|
|
37
|
+
self.services.store.transition_episode(ep.episode_id, ExecutionState.COMPLETED)
|
|
38
|
+
# The episode must remain RUNNING, not silently advance.
|
|
39
|
+
self.assertEqual(self.services.store.get_episode(ep.episode_id).state, ExecutionState.RUNNING)
|
|
40
|
+
|
|
41
|
+
def test_invariant1_completes_after_result_observation(self) -> None:
|
|
42
|
+
ep = self._drive_to_running()
|
|
43
|
+
self.services.store.record_result_observation(
|
|
44
|
+
ep.episode_id, correlation_id=ep.correlation_id, summary="done", verified=True)
|
|
45
|
+
done = self.services.store.transition_episode(ep.episode_id, ExecutionState.COMPLETED)
|
|
46
|
+
self.assertEqual(done.state, ExecutionState.COMPLETED)
|
|
47
|
+
|
|
48
|
+
def test_invariant1_failed_is_exempt(self) -> None:
|
|
49
|
+
# Failure is itself an observed result (Invariant 9): FAILED needs no observation.
|
|
50
|
+
ep = self._drive_to_running()
|
|
51
|
+
failed = self.services.store.transition_episode(ep.episode_id, ExecutionState.FAILED)
|
|
52
|
+
self.assertEqual(failed.state, ExecutionState.FAILED)
|
|
53
|
+
|
|
54
|
+
def test_episode_is_durable_across_service_recreation(self) -> None:
|
|
55
|
+
episode = self.services.new_episode(
|
|
56
|
+
task_ref="cosmos:test:task",
|
|
57
|
+
actor_ref="cosmos:test:actor",
|
|
58
|
+
environment_revision="rev-1",
|
|
59
|
+
)
|
|
60
|
+
self.services.store.transition_episode(
|
|
61
|
+
episode.episode_id,
|
|
62
|
+
ExecutionState.PREPARING,
|
|
63
|
+
expected_state=ExecutionState.CREATED,
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
recreated = build_services(RuntimeConfig(database_path=self.db, environment_ref="cosmos:test"))
|
|
67
|
+
loaded = recreated.store.get_episode(episode.episode_id)
|
|
68
|
+
self.assertIsNotNone(loaded)
|
|
69
|
+
assert loaded is not None
|
|
70
|
+
self.assertEqual(loaded.state, ExecutionState.PREPARING)
|
|
71
|
+
self.assertEqual(loaded.task_ref, "cosmos:test:task")
|
|
72
|
+
self.assertEqual(loaded.actor_ref, "cosmos:test:actor")
|
|
73
|
+
|
|
74
|
+
def test_illegal_transition_is_rejected(self) -> None:
|
|
75
|
+
episode = self.services.new_episode()
|
|
76
|
+
with self.assertRaises(ValueError):
|
|
77
|
+
self.services.store.transition_episode(
|
|
78
|
+
episode.episode_id,
|
|
79
|
+
ExecutionState.COMPLETED,
|
|
80
|
+
expected_state=ExecutionState.CREATED,
|
|
81
|
+
)
|
|
82
|
+
loaded = self.services.store.get_episode(episode.episode_id)
|
|
83
|
+
assert loaded is not None
|
|
84
|
+
self.assertEqual(loaded.state, ExecutionState.CREATED)
|
|
85
|
+
|
|
86
|
+
def test_expected_state_prevents_stale_transition(self) -> None:
|
|
87
|
+
episode = self.services.new_episode()
|
|
88
|
+
self.services.store.transition_episode(
|
|
89
|
+
episode.episode_id,
|
|
90
|
+
ExecutionState.PREPARING,
|
|
91
|
+
expected_state=ExecutionState.CREATED,
|
|
92
|
+
)
|
|
93
|
+
with self.assertRaises(ValueError):
|
|
94
|
+
self.services.store.transition_episode(
|
|
95
|
+
episode.episode_id,
|
|
96
|
+
ExecutionState.READY,
|
|
97
|
+
expected_state=ExecutionState.CREATED,
|
|
98
|
+
)
|
|
99
|
+
|
|
100
|
+
def test_structured_error_persists(self) -> None:
|
|
101
|
+
episode = self.services.new_episode()
|
|
102
|
+
error = RuntimeErrorInfo(code="runtime.bootstrap_failed", message="synthetic", retryable=False)
|
|
103
|
+
self.services.store.transition_episode(
|
|
104
|
+
episode.episode_id,
|
|
105
|
+
ExecutionState.FAILED,
|
|
106
|
+
expected_state=ExecutionState.CREATED,
|
|
107
|
+
error=error,
|
|
108
|
+
)
|
|
109
|
+
loaded = self.services.store.get_episode(episode.episode_id)
|
|
110
|
+
assert loaded is not None
|
|
111
|
+
self.assertEqual(loaded.last_error.code, "runtime.bootstrap_failed")
|
|
112
|
+
|
|
113
|
+
def test_event_stream_persists(self) -> None:
|
|
114
|
+
episode = self.services.new_episode()
|
|
115
|
+
self.services.store.append_event(RuntimeEvent(
|
|
116
|
+
episode_id=episode.episode_id,
|
|
117
|
+
event_type="runtime.synthetic",
|
|
118
|
+
occurred_at=utc_now(),
|
|
119
|
+
correlation_id=episode.correlation_id,
|
|
120
|
+
payload={"value": 1},
|
|
121
|
+
))
|
|
122
|
+
events = self.services.store.list_events(episode.episode_id)
|
|
123
|
+
self.assertEqual([e.event_type for e in events], [
|
|
124
|
+
"runtime.episode.created",
|
|
125
|
+
"runtime.synthetic",
|
|
126
|
+
])
|
|
127
|
+
|
|
128
|
+
def test_health_cli_clean_checkout_contract(self) -> None:
|
|
129
|
+
health_db = Path(self.tempdir.name) / "health.sqlite3"
|
|
130
|
+
proc = subprocess.run(
|
|
131
|
+
[sys.executable, "-m", "runtime.cosmos_runtime", "health", "--db", str(health_db)],
|
|
132
|
+
check=True,
|
|
133
|
+
capture_output=True,
|
|
134
|
+
text=True,
|
|
135
|
+
timeout=600,
|
|
136
|
+
)
|
|
137
|
+
result = json.loads(proc.stdout)
|
|
138
|
+
self.assertEqual(result["status"], "ok")
|
|
139
|
+
self.assertEqual(result["runtime"], "cosmos")
|
|
140
|
+
self.assertEqual(result["store"], "sqlite")
|
|
141
|
+
self.assertTrue(health_db.exists())
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
if __name__ == "__main__":
|
|
145
|
+
unittest.main()
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
"""Unit tests for Cosmos governance gates."""
|
|
2
|
+
|
|
3
|
+
import unittest
|
|
4
|
+
|
|
5
|
+
from runtime.cosmos_runtime.governance.gates import (
|
|
6
|
+
ChangeClass,
|
|
7
|
+
ContextSufficiencyGate,
|
|
8
|
+
ExecutionRequest,
|
|
9
|
+
Gate,
|
|
10
|
+
GatePipeline,
|
|
11
|
+
GateVerdict,
|
|
12
|
+
PermissionGate,
|
|
13
|
+
PlanContinuationGate,
|
|
14
|
+
ResponseGate,
|
|
15
|
+
RiskGate,
|
|
16
|
+
RiskLevel,
|
|
17
|
+
UserInterruptionGate,
|
|
18
|
+
)
|
|
19
|
+
from runtime.cosmos_runtime.governance.scope_types import Scope
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class TestPlanContinuationGate(unittest.TestCase):
|
|
23
|
+
"""Plan continuation must be deterministic; no unnecessary pauses."""
|
|
24
|
+
|
|
25
|
+
def setUp(self):
|
|
26
|
+
self.gate = PlanContinuationGate()
|
|
27
|
+
|
|
28
|
+
def test_approved_plan_with_tasks_passes(self):
|
|
29
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
30
|
+
action="implement", plan_approved=True, plan_tasks_remaining=3))
|
|
31
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
32
|
+
self.assertEqual(r.evidence["tasks_remaining"], 3)
|
|
33
|
+
|
|
34
|
+
def test_completed_plan_blocks(self):
|
|
35
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
36
|
+
action="implement", plan_approved=True, plan_tasks_remaining=0))
|
|
37
|
+
self.assertEqual(r.verdict, GateVerdict.BLOCK)
|
|
38
|
+
|
|
39
|
+
def test_scope_expansion_without_plan_requires_confirmation(self):
|
|
40
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
41
|
+
action="implement", change_class=ChangeClass.C))
|
|
42
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
43
|
+
|
|
44
|
+
def test_scope_reduction_without_plan_requires_confirmation(self):
|
|
45
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
46
|
+
action="implement", change_class=ChangeClass.D))
|
|
47
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
48
|
+
|
|
49
|
+
def test_class_a_and_b_pass_without_plan(self):
|
|
50
|
+
for cls in (ChangeClass.A, ChangeClass.B):
|
|
51
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
52
|
+
action="fix", change_class=cls))
|
|
53
|
+
self.assertEqual(r.verdict, GateVerdict.PASS, cls)
|
|
54
|
+
|
|
55
|
+
def test_is_deterministic(self):
|
|
56
|
+
req = ExecutionRequest(
|
|
57
|
+
action="x", plan_approved=True, plan_tasks_remaining=1)
|
|
58
|
+
r1 = self.gate.evaluate(req)
|
|
59
|
+
r2 = self.gate.evaluate(req)
|
|
60
|
+
self.assertEqual(r1.to_dict(), r2.to_dict())
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
class TestContextSufficiencyGate(unittest.TestCase):
|
|
64
|
+
"""Never answer with retrievable-but-missing context."""
|
|
65
|
+
|
|
66
|
+
def setUp(self):
|
|
67
|
+
self.gate = ContextSufficiencyGate()
|
|
68
|
+
|
|
69
|
+
def test_all_requirements_satisfied(self):
|
|
70
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
71
|
+
action="answer",
|
|
72
|
+
context_requirements=["file", "doc"],
|
|
73
|
+
retrieved_context=[{"kind": "file", "path": "a.py"},
|
|
74
|
+
{"kind": "doc", "path": "b.md"}],
|
|
75
|
+
))
|
|
76
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
77
|
+
|
|
78
|
+
def test_missing_requirement_blocks_with_missing_list(self):
|
|
79
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
80
|
+
action="answer",
|
|
81
|
+
context_requirements=["file", "doc"],
|
|
82
|
+
retrieved_context=[{"kind": "file", "path": "a.py"}],
|
|
83
|
+
))
|
|
84
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONTEXT)
|
|
85
|
+
self.assertEqual(r.evidence["missing"], ["doc"])
|
|
86
|
+
|
|
87
|
+
def test_empty_requirements_passes(self):
|
|
88
|
+
r = self.gate.evaluate(ExecutionRequest(action="answer"))
|
|
89
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
90
|
+
|
|
91
|
+
def test_none_requirement_is_noop(self):
|
|
92
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
93
|
+
action="answer", context_requirements=["none"],
|
|
94
|
+
retrieved_context=[]))
|
|
95
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
class TestUserInterruptionGate(unittest.TestCase):
|
|
99
|
+
"""Model questions that are resolvable must be suppressed."""
|
|
100
|
+
|
|
101
|
+
def setUp(self):
|
|
102
|
+
self.gate = UserInterruptionGate()
|
|
103
|
+
|
|
104
|
+
def test_no_question_passes(self):
|
|
105
|
+
r = self.gate.evaluate(ExecutionRequest(action="answer"))
|
|
106
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
107
|
+
|
|
108
|
+
def test_resolvable_question_suppresses_interruption_without_blocking(self):
|
|
109
|
+
# Reconciliation fix (PR #261 snapshot triage, 2026-09-18): this gate
|
|
110
|
+
# previously returned GateVerdict.BLOCK here, which GatePipeline
|
|
111
|
+
# .overall_verdict() treats as the single worst outcome across every
|
|
112
|
+
# gate — a "don't bother the user, just answer" case would have
|
|
113
|
+
# halted the whole pipeline instead of letting it proceed.
|
|
114
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
115
|
+
action="answer",
|
|
116
|
+
proposed_question="Where is scopes.py?",
|
|
117
|
+
question_resolvable=True,
|
|
118
|
+
))
|
|
119
|
+
self.assertEqual(r.verdict, GateVerdict.SUPPRESS_INTERRUPTION)
|
|
120
|
+
self.assertNotEqual(r.verdict, GateVerdict.BLOCK)
|
|
121
|
+
self.assertIn({"question": "Where is scopes.py?"}, [r.evidence])
|
|
122
|
+
|
|
123
|
+
def test_genuine_decision_routes_to_operator(self):
|
|
124
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
125
|
+
action="answer",
|
|
126
|
+
proposed_question="Deploy to production now?",
|
|
127
|
+
question_resolvable=False,
|
|
128
|
+
))
|
|
129
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
class TestRiskGate(unittest.TestCase):
|
|
133
|
+
"""Risk boundaries are respected and escalate properly."""
|
|
134
|
+
|
|
135
|
+
def setUp(self):
|
|
136
|
+
self.gate = RiskGate()
|
|
137
|
+
|
|
138
|
+
def test_low_risk_local_passes(self):
|
|
139
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
140
|
+
action="read", risk_level=RiskLevel.LOW))
|
|
141
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
142
|
+
|
|
143
|
+
def test_destructive_escalates_to_high(self):
|
|
144
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
145
|
+
action="delete", risk_level=RiskLevel.LOW, destructive=True))
|
|
146
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
147
|
+
self.assertEqual(r.evidence["effective_risk"], "high")
|
|
148
|
+
|
|
149
|
+
def test_secrets_escalate_to_critical(self):
|
|
150
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
151
|
+
action="vault", risk_level=RiskLevel.LOW, touches_secrets=True))
|
|
152
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
153
|
+
self.assertEqual(r.evidence["effective_risk"], "critical")
|
|
154
|
+
|
|
155
|
+
def test_external_escalates_to_medium(self):
|
|
156
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
157
|
+
action="call", risk_level=RiskLevel.LOW, external=True,
|
|
158
|
+
plan_approved=True))
|
|
159
|
+
self.assertEqual(r.evidence["effective_risk"], "medium")
|
|
160
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
161
|
+
|
|
162
|
+
def test_medium_without_plan_needs_confirmation(self):
|
|
163
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
164
|
+
action="modify", risk_level=RiskLevel.MEDIUM))
|
|
165
|
+
self.assertEqual(r.verdict, GateVerdict.REQUIRE_CONFIRMATION)
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
class TestPermissionGate(unittest.TestCase):
|
|
170
|
+
"""Scope boundary enforcement is hard and absolute."""
|
|
171
|
+
|
|
172
|
+
def setUp(self):
|
|
173
|
+
self.gate = PermissionGate()
|
|
174
|
+
self.repo_scope = Scope(
|
|
175
|
+
organization_id="org-a", team_id="t1", project_id="p1",
|
|
176
|
+
repository_id="r1",
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
def test_no_action_scope_passes(self):
|
|
180
|
+
r = self.gate.evaluate(ExecutionRequest(action="x"))
|
|
181
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
182
|
+
|
|
183
|
+
def test_contained_scope_passes(self):
|
|
184
|
+
inside = Scope(
|
|
185
|
+
organization_id="org-a", team_id="t1", project_id="p1",
|
|
186
|
+
repository_id="r1", sandbox_id="s1",
|
|
187
|
+
)
|
|
188
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
189
|
+
action="x",
|
|
190
|
+
request_scope=self.repo_scope,
|
|
191
|
+
action_scope=inside,
|
|
192
|
+
))
|
|
193
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
194
|
+
|
|
195
|
+
def test_outside_scope_blocks(self):
|
|
196
|
+
outside = Scope(organization_id="org-b")
|
|
197
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
198
|
+
action="x",
|
|
199
|
+
request_scope=self.repo_scope,
|
|
200
|
+
action_scope=outside,
|
|
201
|
+
))
|
|
202
|
+
self.assertEqual(r.verdict, GateVerdict.BLOCK)
|
|
203
|
+
|
|
204
|
+
def test_no_permission_held_fails_closed(self):
|
|
205
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
206
|
+
action="x",
|
|
207
|
+
request_scope=None,
|
|
208
|
+
action_scope=Scope(organization_id="org-a"),
|
|
209
|
+
))
|
|
210
|
+
self.assertEqual(r.verdict, GateVerdict.BLOCK)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
class TestResponseGate(unittest.TestCase):
|
|
214
|
+
"""Outputs are checked before reaching the user."""
|
|
215
|
+
|
|
216
|
+
def setUp(self):
|
|
217
|
+
self.gate = ResponseGate()
|
|
218
|
+
|
|
219
|
+
def test_no_response_passes(self):
|
|
220
|
+
r = self.gate.evaluate(ExecutionRequest(action="x"))
|
|
221
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
222
|
+
|
|
223
|
+
def test_clean_response_passes(self):
|
|
224
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
225
|
+
action="x", response_text="Implemented in gates.py, see tests."))
|
|
226
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
227
|
+
|
|
228
|
+
def test_secret_material_is_blocked(self):
|
|
229
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
230
|
+
action="x",
|
|
231
|
+
response_text="Use this header: Bearer abc123",
|
|
232
|
+
))
|
|
233
|
+
self.assertEqual(r.verdict, GateVerdict.BLOCK)
|
|
234
|
+
|
|
235
|
+
def test_completion_claim_without_evidence_is_blocked(self):
|
|
236
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
237
|
+
action="x",
|
|
238
|
+
response_text="All tests pass now.",
|
|
239
|
+
retrieved_context=[],
|
|
240
|
+
))
|
|
241
|
+
self.assertEqual(r.verdict, GateVerdict.BLOCK)
|
|
242
|
+
|
|
243
|
+
def test_completion_claim_with_retrieval_evidence_passes(self):
|
|
244
|
+
r = self.gate.evaluate(ExecutionRequest(
|
|
245
|
+
action="x",
|
|
246
|
+
response_text="All tests pass now.",
|
|
247
|
+
retrieved_context=[{"kind": "test_run", "result": "ok"}],
|
|
248
|
+
))
|
|
249
|
+
self.assertEqual(r.verdict, GateVerdict.PASS)
|
|
250
|
+
|
|
251
|
+
|
|
252
|
+
class TestGatePipeline(unittest.TestCase):
|
|
253
|
+
"""Pipeline runs in order and is fail-closed."""
|
|
254
|
+
|
|
255
|
+
def test_all_pass(self):
|
|
256
|
+
req = ExecutionRequest(
|
|
257
|
+
action="implement",
|
|
258
|
+
change_class=ChangeClass.A,
|
|
259
|
+
risk_level=RiskLevel.LOW,
|
|
260
|
+
)
|
|
261
|
+
results = GatePipeline().evaluate(req)
|
|
262
|
+
self.assertTrue(all(r.passed for r in results))
|
|
263
|
+
self.assertEqual(
|
|
264
|
+
GatePipeline.overall_verdict(results), GateVerdict.PASS)
|
|
265
|
+
|
|
266
|
+
def test_first_block_wins(self):
|
|
267
|
+
req = ExecutionRequest(
|
|
268
|
+
action="deploy", plan_approved=True, plan_tasks_remaining=0,
|
|
269
|
+
)
|
|
270
|
+
results = GatePipeline().evaluate(req)
|
|
271
|
+
self.assertEqual(
|
|
272
|
+
GatePipeline.overall_verdict(results), GateVerdict.BLOCK)
|
|
273
|
+
|
|
274
|
+
def test_gate_malfunction_fails_closed(self):
|
|
275
|
+
class BrokenGate(Gate):
|
|
276
|
+
name = "broken"
|
|
277
|
+
|
|
278
|
+
def evaluate(self, request):
|
|
279
|
+
raise RuntimeError("boom")
|
|
280
|
+
|
|
281
|
+
pipeline = GatePipeline(gates=[BrokenGate()])
|
|
282
|
+
results = pipeline.evaluate(ExecutionRequest(action="x"))
|
|
283
|
+
self.assertEqual(results[0].verdict, GateVerdict.BLOCK)
|
|
284
|
+
self.assertIn("malfunction", results[0].reasons[0])
|
|
285
|
+
|
|
286
|
+
def test_empty_pipeline_blocks(self):
|
|
287
|
+
self.assertEqual(
|
|
288
|
+
GatePipeline.overall_verdict([]), GateVerdict.BLOCK)
|
|
289
|
+
|
|
290
|
+
def test_verdict_precedence(self):
|
|
291
|
+
results = []
|
|
292
|
+
for gate_cls in GatePipeline.DEFAULT_ORDER:
|
|
293
|
+
gate = gate_cls()
|
|
294
|
+
req = ExecutionRequest(
|
|
295
|
+
action="x",
|
|
296
|
+
context_requirements=["doc"],
|
|
297
|
+
proposed_question="ok?",
|
|
298
|
+
question_resolvable=True,
|
|
299
|
+
response_text="Bearer token",
|
|
300
|
+
)
|
|
301
|
+
results.append(gate.evaluate(req))
|
|
302
|
+
self.assertEqual(
|
|
303
|
+
GatePipeline.overall_verdict(results), GateVerdict.BLOCK)
|
|
304
|
+
|
|
305
|
+
def test_resolvable_question_does_not_halt_the_pipeline(self):
|
|
306
|
+
# Regression for the fix above: an otherwise-clean request whose only
|
|
307
|
+
# notable fact is a resolvable proposed question must let execution
|
|
308
|
+
# proceed (PASS-equivalent), not report the pipeline's single worst
|
|
309
|
+
# outcome as BLOCK. Proven to fail on pre-fix code (asserted BLOCK).
|
|
310
|
+
req = ExecutionRequest(
|
|
311
|
+
action="implement",
|
|
312
|
+
change_class=ChangeClass.A,
|
|
313
|
+
risk_level=RiskLevel.LOW,
|
|
314
|
+
proposed_question="Where is scopes.py?",
|
|
315
|
+
question_resolvable=True,
|
|
316
|
+
)
|
|
317
|
+
results = GatePipeline().evaluate(req)
|
|
318
|
+
overall = GatePipeline.overall_verdict(results)
|
|
319
|
+
self.assertNotEqual(overall, GateVerdict.BLOCK)
|
|
320
|
+
self.assertIn(overall, (GateVerdict.PASS, GateVerdict.SUPPRESS_INTERRUPTION))
|
|
321
|
+
interruption_result = next(r for r in results if r.gate == "user_interruption")
|
|
322
|
+
self.assertEqual(interruption_result.verdict, GateVerdict.SUPPRESS_INTERRUPTION)
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
if __name__ == "__main__":
|
|
326
|
+
unittest.main()
|
|
327
|
+
|