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,587 @@
|
|
|
1
|
+
"""Focused tests for the LC1.16 live run monitor (worker S2).
|
|
2
|
+
|
|
3
|
+
Everything runs against throwaway temp directories, fixture progress files,
|
|
4
|
+
fake pids and synthetic receipt history. Nothing touches the real project
|
|
5
|
+
state, the check runner, certification or the obligations ledger.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import contextlib
|
|
11
|
+
import io
|
|
12
|
+
import json
|
|
13
|
+
from tools import cosmos_proc as subprocess
|
|
14
|
+
import sys
|
|
15
|
+
import tempfile
|
|
16
|
+
import unittest
|
|
17
|
+
from datetime import datetime, timedelta, timezone
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
|
|
20
|
+
from tools import cosmos_run_monitor as mon
|
|
21
|
+
|
|
22
|
+
T0 = datetime(2026, 9, 27, 12, 0, 0, tzinfo=timezone.utc)
|
|
23
|
+
FAKE_PID = 999_999_999 # beyond any real pid budget on Windows and POSIX
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
def iso(dt: datetime) -> str:
|
|
27
|
+
return dt.isoformat()
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def make_receipt(duration_s: float, profile: str = "standard", check_id: str = "runtime-unittest") -> dict:
|
|
31
|
+
return {
|
|
32
|
+
"schema": "cosmos.check-receipt/1",
|
|
33
|
+
"started_at": iso(T0),
|
|
34
|
+
"completed_at": iso(T0 + timedelta(seconds=duration_s)),
|
|
35
|
+
"policy": {"profile": profile},
|
|
36
|
+
"checks": [{"id": check_id, "duration_seconds": duration_s}],
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
def make_progress(**overrides) -> dict:
|
|
41
|
+
progress = {
|
|
42
|
+
"schema": "cosmos.run-progress/1",
|
|
43
|
+
"run_id": "run-fixture",
|
|
44
|
+
"objective": "LC1.16 fixture run",
|
|
45
|
+
"work_unit": "LC1.16",
|
|
46
|
+
"pid": FAKE_PID,
|
|
47
|
+
"started_at": iso(T0),
|
|
48
|
+
"elapsed_s": 0,
|
|
49
|
+
"expected_p50_s": None,
|
|
50
|
+
"expected_p95_s": None,
|
|
51
|
+
"phase": "running",
|
|
52
|
+
"shard": 0,
|
|
53
|
+
"check": "runtime-unittest",
|
|
54
|
+
"tests_discovered": 1000,
|
|
55
|
+
"tests_completed": 0,
|
|
56
|
+
"current_test": "runtime.tests.test_example",
|
|
57
|
+
"last_progress_at": iso(T0),
|
|
58
|
+
"cpu_percent": 0.0,
|
|
59
|
+
"worktree": "wt-fixture",
|
|
60
|
+
"failures_so_far": 0,
|
|
61
|
+
"stall": {"state": "ok", "since": None},
|
|
62
|
+
"next_action": "continue",
|
|
63
|
+
}
|
|
64
|
+
progress.update(overrides)
|
|
65
|
+
return progress
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def minimal_state(run_id: str = "run-fixture") -> dict:
|
|
69
|
+
return {
|
|
70
|
+
"schema": mon.SCHEMA_STATE,
|
|
71
|
+
"run_id": run_id,
|
|
72
|
+
"stall": {"state": "ok", "since": None},
|
|
73
|
+
"transitions": [],
|
|
74
|
+
"alert_level": None,
|
|
75
|
+
"last_alert_at": None,
|
|
76
|
+
"hard_alert_count": 0,
|
|
77
|
+
"recovery_count": 0,
|
|
78
|
+
"incidents": [],
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
class MonitorTestCase(unittest.TestCase):
|
|
83
|
+
def setUp(self) -> None:
|
|
84
|
+
self._tmp = tempfile.TemporaryDirectory(prefix="cosmos-run-monitor-s2-")
|
|
85
|
+
self.tmp = Path(self._tmp.name)
|
|
86
|
+
self.monitor_dir = self.tmp / "run-monitor"
|
|
87
|
+
self.receipts_dir = self.tmp / "receipts"
|
|
88
|
+
self.monitor_dir.mkdir()
|
|
89
|
+
self.receipts_dir.mkdir()
|
|
90
|
+
|
|
91
|
+
def tearDown(self) -> None:
|
|
92
|
+
self._tmp.cleanup()
|
|
93
|
+
|
|
94
|
+
# -- helpers ---------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
def write_receipts(self, durations: list[float], profile: str = "standard", check_id: str = "runtime-unittest") -> None:
|
|
97
|
+
start = len(list(self.receipts_dir.glob("chk-fixture*.json")))
|
|
98
|
+
for i, dur in enumerate(durations):
|
|
99
|
+
path = self.receipts_dir / f"chk-fixture{start + i:03d}.json"
|
|
100
|
+
path.write_text(json.dumps(make_receipt(dur, profile, check_id)), encoding="utf-8")
|
|
101
|
+
|
|
102
|
+
def write_progress(self, run_id: str, progress: dict) -> Path:
|
|
103
|
+
path = self.monitor_dir / f"{run_id}.progress.json"
|
|
104
|
+
path.write_text(json.dumps(progress, indent=2), encoding="utf-8")
|
|
105
|
+
return path
|
|
106
|
+
|
|
107
|
+
def cycle(self, run_id: str, now: datetime, sample_s: float = 0.0, record: bool = True, diagnosis=None, policy=None):
|
|
108
|
+
history = mon.historical_distributions(self.receipts_dir)
|
|
109
|
+
factory = None
|
|
110
|
+
if diagnosis is not None:
|
|
111
|
+
factory = lambda pid, pol, sample_s=None, _d=diagnosis: dict(_d)
|
|
112
|
+
return mon.monitor_cycle(
|
|
113
|
+
run_id,
|
|
114
|
+
self.monitor_dir,
|
|
115
|
+
history,
|
|
116
|
+
policy or mon.POLICY,
|
|
117
|
+
now=now,
|
|
118
|
+
sample_s=sample_s,
|
|
119
|
+
record=record,
|
|
120
|
+
diagnosis_factory=factory,
|
|
121
|
+
)
|
|
122
|
+
|
|
123
|
+
@staticmethod
|
|
124
|
+
def dead_diagnosis() -> dict: return {
|
|
125
|
+
"schema": "cosmos.run-monitor-diagnosis/1",
|
|
126
|
+
"available": True,
|
|
127
|
+
"sampler": "fixture",
|
|
128
|
+
"alive": False,
|
|
129
|
+
"health": "dead",
|
|
130
|
+
"children": [],
|
|
131
|
+
"cpu_delta_s": 0.0,
|
|
132
|
+
"reason": "pid-not-in-process-table",
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
def alert_lines(self) -> list[dict]:
|
|
136
|
+
path = self.monitor_dir / "alerts.jsonl"
|
|
137
|
+
if not path.is_file():
|
|
138
|
+
return []
|
|
139
|
+
return [json.loads(line) for line in path.read_text(encoding="utf-8").splitlines() if line.strip()]
|
|
140
|
+
|
|
141
|
+
@contextlib.contextmanager
|
|
142
|
+
def frozen_now(self, when: datetime):
|
|
143
|
+
"""Pin the monitor's wall clock so CLI entry points are deterministic."""
|
|
144
|
+
original = mon._utc_now
|
|
145
|
+
mon._utc_now = lambda: when
|
|
146
|
+
try:
|
|
147
|
+
yield
|
|
148
|
+
finally:
|
|
149
|
+
mon._utc_now = original
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
class HistoryDistributionTests(MonitorTestCase):
|
|
153
|
+
def test_p50_p95_computed_from_receipts_and_corruption_skipped(self):
|
|
154
|
+
durations = [float(v) for v in range(100, 1001, 100)] # 100..1000
|
|
155
|
+
self.write_receipts(durations)
|
|
156
|
+
# known corrupted receipt class (shell-redirect damage) + foreign schema
|
|
157
|
+
(self.receipts_dir / "chk-bad.json").write_text("valid prefix\nEXIT:1\n", encoding="utf-8")
|
|
158
|
+
(self.receipts_dir / "chk-foreign.json").write_text(json.dumps({"schema": "other/1"}), encoding="utf-8")
|
|
159
|
+
|
|
160
|
+
history = mon.historical_distributions(self.receipts_dir)
|
|
161
|
+
self.assertEqual(history["receipts_seen"], 12)
|
|
162
|
+
self.assertEqual(history["receipts_used"], 10)
|
|
163
|
+
self.assertEqual(history["receipts_skipped"], 2)
|
|
164
|
+
self.assertIn("chk-bad.json", history["skipped_files"])
|
|
165
|
+
stats = history["profiles"]["standard"]
|
|
166
|
+
self.assertEqual(stats["n"], 10)
|
|
167
|
+
self.assertEqual(stats["min_s"], 100.0)
|
|
168
|
+
self.assertEqual(stats["max_s"], 1000.0)
|
|
169
|
+
self.assertAlmostEqual(stats["p50_s"], 550.0, places=3)
|
|
170
|
+
self.assertAlmostEqual(stats["p95_s"], 955.0, places=3)
|
|
171
|
+
self.assertAlmostEqual(history["all"]["p95_s"], 955.0, places=3)
|
|
172
|
+
self.assertEqual(history["checks"]["runtime-unittest"]["n"], 10)
|
|
173
|
+
|
|
174
|
+
def test_missing_receipts_dir_is_tolerated(self):
|
|
175
|
+
history = mon.historical_distributions(self.tmp / "does-not-exist")
|
|
176
|
+
self.assertEqual(history["receipts_seen"], 0)
|
|
177
|
+
self.assertIsNone(history["all"])
|
|
178
|
+
self.assertEqual(history["profiles"], {})
|
|
179
|
+
|
|
180
|
+
def test_expected_threshold_precedence(self):
|
|
181
|
+
self.write_receipts([float(v) for v in range(100, 600, 100)]) # 5 standard samples
|
|
182
|
+
self.write_receipts([50.0, 60.0], profile="quick", check_id="quick-check") # too few
|
|
183
|
+
history = mon.historical_distributions(self.receipts_dir)
|
|
184
|
+
|
|
185
|
+
runner = mon.expected_thresholds(
|
|
186
|
+
{"expected_p95_s": 42.0, "expected_p50_s": 21.0}, history, mon.POLICY
|
|
187
|
+
)
|
|
188
|
+
self.assertEqual(runner["source"], "runner")
|
|
189
|
+
self.assertEqual(runner["p95_s"], 42.0)
|
|
190
|
+
|
|
191
|
+
profile = mon.expected_thresholds({"profile": "standard"}, history, mon.POLICY)
|
|
192
|
+
self.assertEqual(profile["source"], "receipts:profile:standard")
|
|
193
|
+
self.assertEqual(profile["samples"], 5)
|
|
194
|
+
|
|
195
|
+
check = mon.expected_thresholds({"check": "runtime-unittest"}, history, mon.POLICY)
|
|
196
|
+
self.assertEqual(check["source"], "receipts:check:runtime-unittest")
|
|
197
|
+
|
|
198
|
+
# insufficient profile samples fall through to all-receipts history
|
|
199
|
+
thin = mon.expected_thresholds({"profile": "quick"}, history, mon.POLICY)
|
|
200
|
+
self.assertEqual(thin["source"], "receipts:all")
|
|
201
|
+
|
|
202
|
+
fallback = mon.expected_thresholds({}, {"profiles": {}, "checks": {}, "all": None}, mon.POLICY)
|
|
203
|
+
self.assertEqual(fallback["source"], "policy-fallback")
|
|
204
|
+
self.assertEqual(fallback["samples"], 0)
|
|
205
|
+
self.assertEqual(fallback["p95_s"], mon.POLICY["fallback_expected_p95_s"])
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
class StallEvaluationTests(MonitorTestCase):
|
|
209
|
+
def test_ok_when_inside_budgets(self):
|
|
210
|
+
progress = make_progress(last_progress_at=iso(T0), started_at=iso(T0))
|
|
211
|
+
evaluation, state = mon.evaluate(
|
|
212
|
+
progress,
|
|
213
|
+
{"p50_s": 1000.0, "p95_s": 3000.0, "source": "receipts:all", "samples": 10},
|
|
214
|
+
mon.POLICY,
|
|
215
|
+
minimal_state(),
|
|
216
|
+
now=T0 + timedelta(seconds=60),
|
|
217
|
+
)
|
|
218
|
+
self.assertEqual(evaluation["stall"]["state"], "ok")
|
|
219
|
+
self.assertIsNone(evaluation["stall"]["since"])
|
|
220
|
+
self.assertEqual(evaluation["reasons"], [])
|
|
221
|
+
self.assertEqual(state["stall"]["state"], "ok")
|
|
222
|
+
|
|
223
|
+
def test_soft_on_no_progress_at_five_minutes(self):
|
|
224
|
+
progress = make_progress(last_progress_at=iso(T0), started_at=iso(T0))
|
|
225
|
+
evaluation, _ = mon.evaluate(
|
|
226
|
+
progress,
|
|
227
|
+
{"p50_s": 1000.0, "p95_s": 3000.0, "source": "receipts:all", "samples": 10},
|
|
228
|
+
mon.POLICY,
|
|
229
|
+
minimal_state(),
|
|
230
|
+
now=T0 + timedelta(seconds=mon.POLICY["soft_no_progress_s"] + 1),
|
|
231
|
+
)
|
|
232
|
+
self.assertEqual(evaluation["stall"]["state"], "soft")
|
|
233
|
+
self.assertIn("no-progress", evaluation["reasons"])
|
|
234
|
+
self.assertEqual(evaluation["stall"]["since"], iso(T0 + timedelta(seconds=301)))
|
|
235
|
+
|
|
236
|
+
def test_immediate_soft_when_elapsed_materially_exceeds_p95(self):
|
|
237
|
+
# progress is fresh (no no-progress trigger) but the run is past p95
|
|
238
|
+
# (yet still inside the hard bound, which would be a different test)
|
|
239
|
+
progress = make_progress(last_progress_at=iso(T0 + timedelta(seconds=109)), started_at=iso(T0))
|
|
240
|
+
evaluation, _ = mon.evaluate(
|
|
241
|
+
progress,
|
|
242
|
+
{"p50_s": 100.0, "p95_s": 100.0, "source": "receipts:profile:standard", "samples": 73},
|
|
243
|
+
mon.POLICY,
|
|
244
|
+
minimal_state(),
|
|
245
|
+
now=T0 + timedelta(seconds=110),
|
|
246
|
+
)
|
|
247
|
+
self.assertEqual(evaluation["stall"]["state"], "soft")
|
|
248
|
+
self.assertIn("historical-p95-overrun", evaluation["reasons"])
|
|
249
|
+
self.assertNotIn("no-progress", evaluation["reasons"])
|
|
250
|
+
self.assertTrue(evaluation["over_p95"])
|
|
251
|
+
self.assertGreater(evaluation["over_p95_by_s"], 5.0)
|
|
252
|
+
|
|
253
|
+
def test_hard_stall_bounds_and_ladder_with_since(self):
|
|
254
|
+
progress = make_progress(last_progress_at=iso(T0), started_at=iso(T0))
|
|
255
|
+
expected = {"p50_s": 1000.0, "p95_s": 3000.0, "source": "receipts:all", "samples": 10}
|
|
256
|
+
soft_at = T0 + timedelta(seconds=301)
|
|
257
|
+
_, state = mon.evaluate(progress, expected, mon.POLICY, minimal_state(), now=soft_at)
|
|
258
|
+
self.assertEqual(state["stall"]["state"], "soft")
|
|
259
|
+
soft_since = state["stall"]["since"]
|
|
260
|
+
|
|
261
|
+
later = T0 + timedelta(seconds=mon.POLICY["hard_no_progress_s"] + 1)
|
|
262
|
+
evaluation, state = mon.evaluate(progress, expected, mon.POLICY, state, now=later)
|
|
263
|
+
self.assertEqual(evaluation["stall"]["state"], "hard")
|
|
264
|
+
self.assertIn("no-progress-hard", evaluation["reasons"])
|
|
265
|
+
# ladder: the stall *episode* onset (soft) survives the soft -> hard
|
|
266
|
+
# escalation, while state_since records the hard step itself
|
|
267
|
+
self.assertEqual(state["stall"]["since"], soft_since)
|
|
268
|
+
self.assertEqual(state["stall"]["state_since"], iso(later))
|
|
269
|
+
self.assertEqual(
|
|
270
|
+
[t["to"] for t in state["transitions"]],
|
|
271
|
+
["soft", "hard"],
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
# progress resumes -> honest recovery, since cleared, transition logged
|
|
275
|
+
recovered = make_progress(last_progress_at=iso(later), started_at=iso(T0))
|
|
276
|
+
evaluation, state = mon.evaluate(recovered, expected, mon.POLICY, state, now=later + timedelta(seconds=5))
|
|
277
|
+
self.assertEqual(evaluation["stall"]["state"], "ok")
|
|
278
|
+
self.assertIsNone(state["stall"]["since"])
|
|
279
|
+
self.assertEqual(state["recovery_count"], 1)
|
|
280
|
+
self.assertEqual(state["transitions"][-1]["to"], "ok")
|
|
281
|
+
|
|
282
|
+
def test_hard_on_elapsed_bounds_not_only_no_progress(self):
|
|
283
|
+
progress = make_progress(last_progress_at=iso(T0 + timedelta(seconds=3600)), started_at=iso(T0))
|
|
284
|
+
expected = {"p50_s": 100.0, "p95_s": 100.0, "source": "receipts:all", "samples": 10}
|
|
285
|
+
evaluation, _ = mon.evaluate(
|
|
286
|
+
progress, expected, mon.POLICY, minimal_state(),
|
|
287
|
+
now=T0 + timedelta(seconds=3600 + int(mon.POLICY["hard_elapsed_p95_factor"] * 100) + 1),
|
|
288
|
+
)
|
|
289
|
+
self.assertEqual(evaluation["stall"]["state"], "hard")
|
|
290
|
+
self.assertIn("elapsed-hard-bound", evaluation["reasons"])
|
|
291
|
+
|
|
292
|
+
def test_terminal_run_is_not_stalled(self):
|
|
293
|
+
progress = make_progress(phase="completed", last_progress_at=iso(T0), started_at=iso(T0))
|
|
294
|
+
evaluation, _ = mon.evaluate(
|
|
295
|
+
progress, {"p50_s": 1.0, "p95_s": 1.0, "source": "receipts:all", "samples": 10},
|
|
296
|
+
mon.POLICY, minimal_state(), now=T0 + timedelta(seconds=99999),
|
|
297
|
+
)
|
|
298
|
+
self.assertEqual(evaluation["stall"]["state"], "ok")
|
|
299
|
+
self.assertTrue(evaluation["terminal"])
|
|
300
|
+
|
|
301
|
+
|
|
302
|
+
class StatusAndResponseTests(MonitorTestCase):
|
|
303
|
+
def test_no_run_is_honest_and_not_an_error(self):
|
|
304
|
+
buf = io.StringIO()
|
|
305
|
+
with contextlib.redirect_stdout(buf):
|
|
306
|
+
code = mon.main([
|
|
307
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
308
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
309
|
+
"--json", "status",
|
|
310
|
+
])
|
|
311
|
+
self.assertEqual(code, 0)
|
|
312
|
+
payload = json.loads(buf.getvalue())
|
|
313
|
+
self.assertEqual(payload["status"], "no-run")
|
|
314
|
+
self.assertIn("no run", payload["message"])
|
|
315
|
+
self.assertFalse((self.monitor_dir / "alerts.jsonl").exists())
|
|
316
|
+
|
|
317
|
+
def test_explicit_unknown_run_id_is_no_run(self):
|
|
318
|
+
buf = io.StringIO()
|
|
319
|
+
with contextlib.redirect_stdout(buf):
|
|
320
|
+
code = mon.main([
|
|
321
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
322
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
323
|
+
"--json", "status", "no-such-run",
|
|
324
|
+
])
|
|
325
|
+
self.assertEqual(code, 0)
|
|
326
|
+
self.assertEqual(json.loads(buf.getvalue())["status"], "no-run")
|
|
327
|
+
|
|
328
|
+
def test_soft_stall_surfaces_alert_and_preserves_evidence(self):
|
|
329
|
+
self.write_receipts([float(v) for v in range(100, 601, 100)])
|
|
330
|
+
self.write_progress("run-fixture", make_progress(
|
|
331
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
332
|
+
))
|
|
333
|
+
now = T0 + timedelta(seconds=mon.POLICY["soft_no_progress_s"] + 1)
|
|
334
|
+
result = self.cycle("run-fixture", now, diagnosis=self.dead_diagnosis())
|
|
335
|
+
|
|
336
|
+
self.assertEqual(result["status"], "soft")
|
|
337
|
+
self.assertEqual(result["evaluation"]["stall"]["state"], "soft")
|
|
338
|
+
self.assertEqual(result["diagnosis"]["health"], "dead")
|
|
339
|
+
|
|
340
|
+
alerts = self.alert_lines()
|
|
341
|
+
self.assertEqual(len(alerts), 1)
|
|
342
|
+
alert = alerts[0]
|
|
343
|
+
self.assertEqual(alert["schema"], mon.SCHEMA_ALERT)
|
|
344
|
+
self.assertEqual(alert["level"], "soft")
|
|
345
|
+
self.assertEqual(alert["diagnosis"]["health"], "dead")
|
|
346
|
+
self.assertEqual(alert["recommended"]["action"], mon.ACTION_BOUNDED_RETRY)
|
|
347
|
+
self.assertEqual(alert["incident_path"], result["incident_path"])
|
|
348
|
+
|
|
349
|
+
incident = Path(result["incident_path"])
|
|
350
|
+
self.assertTrue(incident.is_file())
|
|
351
|
+
self.assertTrue(str(incident).startswith(str(self.monitor_dir / "incidents" / "run-fixture")))
|
|
352
|
+
payload = json.loads(incident.read_text(encoding="utf-8"))
|
|
353
|
+
self.assertEqual(payload["schema"], mon.SCHEMA_INCIDENT)
|
|
354
|
+
self.assertEqual(payload["stall"]["state"], "soft")
|
|
355
|
+
self.assertEqual(payload["progress"]["run_id"], "run-fixture")
|
|
356
|
+
self.assertEqual(payload["diagnosis"]["health"], "dead")
|
|
357
|
+
self.assertIn("evaluation", payload)
|
|
358
|
+
self.assertIn("policy_digest", payload)
|
|
359
|
+
self.assertIn("-soft.json", incident.name)
|
|
360
|
+
|
|
361
|
+
state = mon.load_state(self.monitor_dir, "run-fixture")
|
|
362
|
+
self.assertEqual(state["stall"]["state"], "soft")
|
|
363
|
+
self.assertEqual(len(state["incidents"]), 1)
|
|
364
|
+
|
|
365
|
+
def test_alert_dedupe_respects_repeat_interval(self):
|
|
366
|
+
self.write_progress("run-fixture", make_progress(
|
|
367
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
368
|
+
))
|
|
369
|
+
base = T0 + timedelta(seconds=mon.POLICY["soft_no_progress_s"] + 1)
|
|
370
|
+
self.cycle("run-fixture", base, diagnosis=self.dead_diagnosis())
|
|
371
|
+
self.cycle("run-fixture", base + timedelta(seconds=60), diagnosis=self.dead_diagnosis())
|
|
372
|
+
self.assertEqual(len(self.alert_lines()), 1)
|
|
373
|
+
self.cycle(
|
|
374
|
+
"run-fixture",
|
|
375
|
+
base + timedelta(seconds=mon.POLICY["alert_repeat_s"] + 61),
|
|
376
|
+
diagnosis=self.dead_diagnosis(),
|
|
377
|
+
)
|
|
378
|
+
self.assertEqual(len(self.alert_lines()), 2)
|
|
379
|
+
|
|
380
|
+
def test_stall_state_persists_between_invocations(self):
|
|
381
|
+
self.write_progress("run-fixture", make_progress(
|
|
382
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
383
|
+
))
|
|
384
|
+
soft_at = T0 + timedelta(seconds=mon.POLICY["soft_no_progress_s"] + 1)
|
|
385
|
+
first = self.cycle("run-fixture", soft_at, diagnosis=self.dead_diagnosis())
|
|
386
|
+
second = self.cycle("run-fixture", soft_at + timedelta(seconds=30), record=False, diagnosis=self.dead_diagnosis())
|
|
387
|
+
self.assertEqual(first["evaluation"]["stall"]["since"], second["evaluation"]["stall"]["since"])
|
|
388
|
+
state_file = mon.state_path(self.monitor_dir, "run-fixture")
|
|
389
|
+
self.assertTrue(state_file.is_file())
|
|
390
|
+
persisted = json.loads(state_file.read_text(encoding="utf-8"))
|
|
391
|
+
self.assertEqual(persisted["stall"], first["evaluation"]["stall"])
|
|
392
|
+
|
|
393
|
+
def test_hard_stall_exit_code_and_quarantine_hook_after_retry_budget(self):
|
|
394
|
+
self.write_progress("run-fixture", make_progress(
|
|
395
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
396
|
+
))
|
|
397
|
+
hard_at = T0 + timedelta(seconds=mon.POLICY["hard_no_progress_s"] + 1)
|
|
398
|
+
first = self.cycle("run-fixture", hard_at, diagnosis=self.dead_diagnosis())
|
|
399
|
+
self.assertEqual(first["status"], "hard")
|
|
400
|
+
self.assertEqual(first["recommended"]["action"], mon.ACTION_BOUNDED_RETRY)
|
|
401
|
+
|
|
402
|
+
second = self.cycle(
|
|
403
|
+
"run-fixture",
|
|
404
|
+
hard_at + timedelta(seconds=mon.POLICY["alert_repeat_s"] + 1),
|
|
405
|
+
diagnosis=self.dead_diagnosis(),
|
|
406
|
+
)
|
|
407
|
+
self.assertEqual(second["recommended"]["action"], mon.ACTION_QUARANTINE_REPLACE)
|
|
408
|
+
self.assertIn("quarantine_replace", second["recommended"]["policy_hooks"])
|
|
409
|
+
self.assertEqual(len(self.alert_lines()), 2)
|
|
410
|
+
|
|
411
|
+
frozen = hard_at + timedelta(seconds=mon.POLICY["alert_repeat_s"] + 62)
|
|
412
|
+
buf = io.StringIO()
|
|
413
|
+
with self.frozen_now(frozen), contextlib.redirect_stdout(buf):
|
|
414
|
+
code = mon.main([
|
|
415
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
416
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
417
|
+
"--json", "status", "run-fixture",
|
|
418
|
+
])
|
|
419
|
+
self.assertEqual(code, 1) # hard stall is machine-visible to callers
|
|
420
|
+
|
|
421
|
+
def test_policy_json_override_changes_budget(self):
|
|
422
|
+
override = self.tmp / "policy.json"
|
|
423
|
+
override.write_text(json.dumps({"schema": mon.SCHEMA_POLICY, "soft_no_progress_s": 10}), encoding="utf-8")
|
|
424
|
+
policy = mon.load_policy(override)
|
|
425
|
+
self.assertEqual(policy["soft_no_progress_s"], 10)
|
|
426
|
+
self.assertEqual(policy["hard_no_progress_s"], mon.POLICY["hard_no_progress_s"]) # merged, not replaced
|
|
427
|
+
|
|
428
|
+
self.write_progress("run-fixture", make_progress(
|
|
429
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
430
|
+
))
|
|
431
|
+
result = self.cycle("run-fixture", T0 + timedelta(seconds=30), policy=policy, diagnosis=self.dead_diagnosis())
|
|
432
|
+
self.assertEqual(result["evaluation"]["stall"]["state"], "soft")
|
|
433
|
+
|
|
434
|
+
def test_watch_loop_streams_and_exits_nonzero_on_hard(self):
|
|
435
|
+
self.write_progress("run-fixture", make_progress(
|
|
436
|
+
last_progress_at=iso(T0), started_at=iso(T0),
|
|
437
|
+
))
|
|
438
|
+
buf = io.StringIO()
|
|
439
|
+
with self.frozen_now(T0 + timedelta(seconds=10000)), contextlib.redirect_stdout(buf):
|
|
440
|
+
code = mon.main([
|
|
441
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
442
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
443
|
+
"--json", "watch", "run-fixture",
|
|
444
|
+
"--count", "2", "--interval", "0", "--sample", "0",
|
|
445
|
+
])
|
|
446
|
+
lines = [json.loads(line) for line in buf.getvalue().splitlines() if line.strip()]
|
|
447
|
+
self.assertEqual(len(lines), 2)
|
|
448
|
+
self.assertEqual(lines[0]["schema"], "cosmos.run-monitor-status/1")
|
|
449
|
+
self.assertEqual(lines[-1]["evaluation"]["stall"]["state"], "hard")
|
|
450
|
+
self.assertEqual(code, 1)
|
|
451
|
+
self.assertEqual(len(self.alert_lines()), 1) # deduped across watch iterations
|
|
452
|
+
|
|
453
|
+
def test_watch_terminal_run_exits_zero(self):
|
|
454
|
+
self.write_progress("run-fixture", make_progress(phase="completed"))
|
|
455
|
+
buf = io.StringIO()
|
|
456
|
+
with self.frozen_now(T0 + timedelta(seconds=10)), contextlib.redirect_stdout(buf):
|
|
457
|
+
code = mon.main([
|
|
458
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
459
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
460
|
+
"watch", "run-fixture", "--count", "3", "--interval", "0", "--sample", "0",
|
|
461
|
+
])
|
|
462
|
+
self.assertEqual(code, 0)
|
|
463
|
+
self.assertIn("completed", buf.getvalue())
|
|
464
|
+
|
|
465
|
+
def test_history_cli_json(self):
|
|
466
|
+
self.write_receipts([float(v) for v in range(100, 600, 100)])
|
|
467
|
+
buf = io.StringIO()
|
|
468
|
+
with contextlib.redirect_stdout(buf):
|
|
469
|
+
code = mon.main([
|
|
470
|
+
"--monitor-dir", str(self.monitor_dir),
|
|
471
|
+
"--receipts-dir", str(self.receipts_dir),
|
|
472
|
+
"--json", "history",
|
|
473
|
+
])
|
|
474
|
+
self.assertEqual(code, 0)
|
|
475
|
+
payload = json.loads(buf.getvalue())
|
|
476
|
+
self.assertEqual(payload["profiles"]["standard"]["n"], 5)
|
|
477
|
+
self.assertAlmostEqual(payload["profiles"]["standard"]["p50_s"], 300.0, places=3)
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
class RecommendationTests(unittest.TestCase):
|
|
481
|
+
def _eval(self, level: str, reasons: list[str]) -> dict:
|
|
482
|
+
return {"stall": {"state": level, "since": "x"}, "reasons": reasons}
|
|
483
|
+
|
|
484
|
+
def _diag(self, health: str) -> dict:
|
|
485
|
+
return {"health": health}
|
|
486
|
+
|
|
487
|
+
def test_action_matrix(self):
|
|
488
|
+
cases = [
|
|
489
|
+
("ok", [], "unknown", mon.ACTION_CONTINUE_MONITORING),
|
|
490
|
+
("soft", ["no-progress"], "active", mon.ACTION_CONTINUE_INDEPENDENT),
|
|
491
|
+
("soft", ["no-progress"], "idle", mon.ACTION_REPLAN_ROUTE),
|
|
492
|
+
("soft", ["no-progress"], "dead", mon.ACTION_BOUNDED_RETRY),
|
|
493
|
+
("soft", ["no-progress"], "unknown", mon.ACTION_REPLAN_ROUTE),
|
|
494
|
+
("soft", ["historical-p95-overrun"], "active", mon.ACTION_REPLAN_ROUTE),
|
|
495
|
+
("hard", ["no-progress-hard"], "active", mon.ACTION_REPLAN_ROUTE),
|
|
496
|
+
("hard", ["no-progress-hard"], "idle", mon.ACTION_REPLAN_ROUTE),
|
|
497
|
+
("hard", ["no-progress-hard"], "unknown", mon.ACTION_REPLAN_ROUTE),
|
|
498
|
+
("hard", ["no-progress-hard"], "dead", mon.ACTION_BOUNDED_RETRY),
|
|
499
|
+
]
|
|
500
|
+
for level, reasons, health, expected in cases:
|
|
501
|
+
with self.subTest(level=level, health=health, reasons=reasons):
|
|
502
|
+
rec = mon.recommend(self._eval(level, reasons), self._diag(health), mon.POLICY, minimal_state())
|
|
503
|
+
self.assertEqual(rec["action"], expected)
|
|
504
|
+
|
|
505
|
+
exhausted = minimal_state()
|
|
506
|
+
exhausted["hard_alert_count"] = mon.POLICY["bounded_retry_count"] + 1
|
|
507
|
+
rec = mon.recommend(self._eval("hard", ["no-progress-hard"]), self._diag("dead"), mon.POLICY, exhausted)
|
|
508
|
+
self.assertEqual(rec["action"], mon.ACTION_QUARANTINE_REPLACE)
|
|
509
|
+
self.assertIn("quarantine_replace", rec["policy_hooks"])
|
|
510
|
+
|
|
511
|
+
|
|
512
|
+
class DiagnosisTests(unittest.TestCase):
|
|
513
|
+
def test_fail_closed_when_no_sampler(self):
|
|
514
|
+
result = mon.diagnose(
|
|
515
|
+
1234,
|
|
516
|
+
mon.POLICY,
|
|
517
|
+
sample_s=0.0,
|
|
518
|
+
snapshot=lambda: (False, {}, "no-windows-sampler"),
|
|
519
|
+
)
|
|
520
|
+
self.assertFalse(result["available"])
|
|
521
|
+
self.assertEqual(result["health"], "unknown")
|
|
522
|
+
self.assertIsNone(result["alive"])
|
|
523
|
+
self.assertNotIn(result["health"], ("active", "idle"))
|
|
524
|
+
|
|
525
|
+
def test_fake_pid_never_reports_healthy(self):
|
|
526
|
+
result = mon.diagnose(FAKE_PID, mon.POLICY, sample_s=0.0)
|
|
527
|
+
# either the OS sampled and the pid is absent (dead), or sampling is
|
|
528
|
+
# unavailable - both must fail closed, never active/idle
|
|
529
|
+
self.assertIn(result["health"], ("dead", "unknown"))
|
|
530
|
+
if result["available"]:
|
|
531
|
+
self.assertFalse(result["alive"])
|
|
532
|
+
|
|
533
|
+
def test_tree_diagnosis_uses_real_cpu_delta_with_injected_sampler(self):
|
|
534
|
+
calls = {"n": 0}
|
|
535
|
+
table_parent = {
|
|
536
|
+
100: {"ppid": 1, "name": "parent", "cpu_s": 1.0},
|
|
537
|
+
101: {"ppid": 100, "name": "child", "cpu_s": 0.5},
|
|
538
|
+
1: {"ppid": 0, "name": "init", "cpu_s": 0.0},
|
|
539
|
+
}
|
|
540
|
+
table_child = {
|
|
541
|
+
100: {"ppid": 1, "name": "parent", "cpu_s": 1.2},
|
|
542
|
+
101: {"ppid": 100, "name": "child", "cpu_s": 0.9},
|
|
543
|
+
1: {"ppid": 0, "name": "init", "cpu_s": 0.0},
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
def snapshot():
|
|
547
|
+
calls["n"] += 1
|
|
548
|
+
return True, (table_parent if calls["n"] == 1 else table_child), "fixture"
|
|
549
|
+
|
|
550
|
+
result = mon.diagnose(100, mon.POLICY, sample_s=1.0, sleeper=lambda _s: None, snapshot=snapshot)
|
|
551
|
+
self.assertTrue(result["available"])
|
|
552
|
+
self.assertTrue(result["alive"])
|
|
553
|
+
self.assertEqual(result["health"], "active")
|
|
554
|
+
self.assertAlmostEqual(result["cpu_delta_s"], 0.6, places=3)
|
|
555
|
+
self.assertAlmostEqual(result["descendant_cpu_delta_s"], 0.4, places=3)
|
|
556
|
+
self.assertEqual([c["pid"] for c in result["children"]], [101])
|
|
557
|
+
self.assertEqual(result["cpu_percent"], 60.0)
|
|
558
|
+
|
|
559
|
+
# idle: no CPU movement in the window
|
|
560
|
+
calls["n"] = 0
|
|
561
|
+
result = mon.diagnose(100, mon.POLICY, sample_s=1.0, sleeper=lambda _s: None,
|
|
562
|
+
snapshot=lambda: (True, dict(table_parent), "fixture"))
|
|
563
|
+
self.assertEqual(result["health"], "idle")
|
|
564
|
+
|
|
565
|
+
@unittest.skipUnless(sys.platform in ("win32", "linux", "darwin"), "unsupported platform")
|
|
566
|
+
def test_live_process_is_sampled_from_the_real_os(self):
|
|
567
|
+
proc = subprocess.Popen([sys.executable, "-c", "while True:\n pass"])
|
|
568
|
+
try:
|
|
569
|
+
result = mon.diagnose(proc.pid, mon.POLICY, sample_s=0.4)
|
|
570
|
+
if not result["available"] or result["cpu_delta_s"] is None:
|
|
571
|
+
self.skipTest(f"no usable OS sampler: {result.get('sampler')} / {result.get('reason')}")
|
|
572
|
+
self.assertTrue(result["alive"])
|
|
573
|
+
self.assertEqual(result["health"], "active")
|
|
574
|
+
self.assertGreaterEqual(result["cpu_delta_s"], mon.POLICY["cpu_active_threshold_s"])
|
|
575
|
+
finally:
|
|
576
|
+
proc.kill()
|
|
577
|
+
proc.wait(timeout=30)
|
|
578
|
+
|
|
579
|
+
# after the process is gone, liveness must report dead, never healthy
|
|
580
|
+
gone = mon.diagnose(proc.pid, mon.POLICY, sample_s=0.0)
|
|
581
|
+
self.assertIn(gone["health"], ("dead", "unknown"))
|
|
582
|
+
if gone["available"]:
|
|
583
|
+
self.assertFalse(gone["alive"])
|
|
584
|
+
|
|
585
|
+
|
|
586
|
+
if __name__ == "__main__":
|
|
587
|
+
unittest.main()
|