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,427 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""Reference Cosmos Phase 6 authorization evaluator.
|
|
3
|
+
|
|
4
|
+
Semantic proof only. This is not the Phase 7 production enforcement runtime.
|
|
5
|
+
The evaluator deliberately ignores persona/prompt/context claims as sources of
|
|
6
|
+
authority and uses only governed capability/approval/delegation state.
|
|
7
|
+
"""
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import argparse
|
|
11
|
+
import hashlib
|
|
12
|
+
import json
|
|
13
|
+
from datetime import datetime, timezone
|
|
14
|
+
from pathlib import Path
|
|
15
|
+
from typing import Any
|
|
16
|
+
|
|
17
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
18
|
+
POLICY = "cosmos.authorization.reference/1"
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def load_json(path: Path) -> Any:
|
|
22
|
+
return json.loads(path.read_text())
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def parse_time(value: str) -> datetime:
|
|
26
|
+
return datetime.fromisoformat(value.replace("Z", "+00:00")).astimezone(timezone.utc)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def stable_digest(value: Any) -> str:
|
|
30
|
+
raw = json.dumps(value, sort_keys=True, separators=(",", ":")).encode()
|
|
31
|
+
return hashlib.sha256(raw).hexdigest()
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def valid_time(record: dict[str, Any], now: datetime) -> tuple[bool, str | None]:
|
|
35
|
+
if record.get("revoked", False):
|
|
36
|
+
return False, "capability_revoked"
|
|
37
|
+
if record.get("valid_from") and now < parse_time(record["valid_from"]):
|
|
38
|
+
return False, "capability_not_yet_valid"
|
|
39
|
+
if record.get("valid_until") and now >= parse_time(record["valid_until"]):
|
|
40
|
+
return False, "capability_expired"
|
|
41
|
+
return True, None
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def action_match(cap_action: str, attempted: str) -> bool:
|
|
45
|
+
return cap_action == attempted
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def resource_match(resources: list[Any], attempted: Any) -> bool:
|
|
49
|
+
return attempted in resources
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def constraints_match(constraints: dict[str, Any], parameters: dict[str, Any]) -> bool:
|
|
53
|
+
for key, allowed in constraints.items():
|
|
54
|
+
actual = parameters.get(key)
|
|
55
|
+
if isinstance(allowed, list):
|
|
56
|
+
if actual not in allowed:
|
|
57
|
+
return False
|
|
58
|
+
elif actual != allowed:
|
|
59
|
+
return False
|
|
60
|
+
return True
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
def context_match(record: dict[str, Any], effect: dict[str, Any]) -> bool:
|
|
64
|
+
for key in ("task_ref", "session_ref", "maintenance_run_ref"):
|
|
65
|
+
expected = record.get(key)
|
|
66
|
+
if expected is not None and effect.get(key) != expected:
|
|
67
|
+
return False
|
|
68
|
+
return True
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def delegation_match(
|
|
72
|
+
state: dict[str, Any],
|
|
73
|
+
capability: dict[str, Any],
|
|
74
|
+
actor_ref: str,
|
|
75
|
+
effect: dict[str, Any],
|
|
76
|
+
now: datetime,
|
|
77
|
+
) -> tuple[bool, list[str]]:
|
|
78
|
+
if actor_ref in capability.get("grantee_refs", []):
|
|
79
|
+
return True, []
|
|
80
|
+
|
|
81
|
+
for d in state.get("delegations", []):
|
|
82
|
+
if d.get("delegate_ref") != actor_ref:
|
|
83
|
+
continue
|
|
84
|
+
if d.get("delegator_ref") not in capability.get("grantee_refs", []):
|
|
85
|
+
continue
|
|
86
|
+
if d.get("revoked", False):
|
|
87
|
+
continue
|
|
88
|
+
if d.get("valid_until") and now >= parse_time(d["valid_until"]):
|
|
89
|
+
continue
|
|
90
|
+
if d.get("task_ref") and d.get("task_ref") != effect.get("task_ref"):
|
|
91
|
+
continue
|
|
92
|
+
if effect["action"] not in d.get("actions", []):
|
|
93
|
+
continue
|
|
94
|
+
if effect["resource_ref"] not in d.get("resources", []):
|
|
95
|
+
continue
|
|
96
|
+
return True, [d["delegation_id"]]
|
|
97
|
+
return False, []
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def approval_match(
|
|
101
|
+
state: dict[str, Any],
|
|
102
|
+
actor_ref: str,
|
|
103
|
+
effect: dict[str, Any],
|
|
104
|
+
now: datetime,
|
|
105
|
+
) -> tuple[bool, list[str]]:
|
|
106
|
+
matched = []
|
|
107
|
+
for a in state.get("approvals", []):
|
|
108
|
+
if a.get("state") != "active":
|
|
109
|
+
continue
|
|
110
|
+
if a.get("beneficiary_actor_ref") != actor_ref:
|
|
111
|
+
continue
|
|
112
|
+
if a.get("action") != effect["action"]:
|
|
113
|
+
continue
|
|
114
|
+
if effect["resource_ref"] not in a.get("resources", []):
|
|
115
|
+
continue
|
|
116
|
+
if not context_match(a, effect):
|
|
117
|
+
continue
|
|
118
|
+
if a.get("valid_from") and now < parse_time(a["valid_from"]):
|
|
119
|
+
continue
|
|
120
|
+
if a.get("valid_until") and now >= parse_time(a["valid_until"]):
|
|
121
|
+
continue
|
|
122
|
+
if not constraints_match(a.get("constraints", {}), effect.get("parameters", {})):
|
|
123
|
+
continue
|
|
124
|
+
matched.append(a["approval_id"])
|
|
125
|
+
return bool(matched), matched
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def capability_candidates(
|
|
129
|
+
state: dict[str, Any],
|
|
130
|
+
actor_ref: str,
|
|
131
|
+
effect: dict[str, Any],
|
|
132
|
+
now: datetime,
|
|
133
|
+
) -> list[dict[str, Any]]:
|
|
134
|
+
out = []
|
|
135
|
+
for cap in state.get("capabilities", []):
|
|
136
|
+
direct_or_delegated, delegation_refs = delegation_match(state, cap, actor_ref, effect, now)
|
|
137
|
+
if not direct_or_delegated:
|
|
138
|
+
continue
|
|
139
|
+
if not action_match(cap["action"], effect["action"]):
|
|
140
|
+
continue
|
|
141
|
+
if not resource_match(cap.get("resources", []), effect["resource_ref"]):
|
|
142
|
+
continue
|
|
143
|
+
if not context_match(cap, effect):
|
|
144
|
+
continue
|
|
145
|
+
if not constraints_match(cap.get("constraints", {}), effect.get("parameters", {})):
|
|
146
|
+
continue
|
|
147
|
+
current, reason = valid_time(cap, now)
|
|
148
|
+
out.append({
|
|
149
|
+
"capability": cap,
|
|
150
|
+
"delegation_refs": delegation_refs,
|
|
151
|
+
"current": current,
|
|
152
|
+
"invalid_reason": reason,
|
|
153
|
+
})
|
|
154
|
+
return out
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
def derive_envelope(state: dict[str, Any], actor_ref: str, effect_context: dict[str, Any], now: datetime) -> dict[str, Any]:
|
|
158
|
+
entries = []
|
|
159
|
+
for cap in state.get("capabilities", []):
|
|
160
|
+
direct = actor_ref in cap.get("grantee_refs", [])
|
|
161
|
+
delegated = any(
|
|
162
|
+
d.get("delegate_ref") == actor_ref
|
|
163
|
+
and d.get("delegator_ref") in cap.get("grantee_refs", [])
|
|
164
|
+
and not d.get("revoked", False)
|
|
165
|
+
and (not d.get("valid_until") or now < parse_time(d["valid_until"]))
|
|
166
|
+
for d in state.get("delegations", [])
|
|
167
|
+
)
|
|
168
|
+
if not (direct or delegated):
|
|
169
|
+
continue
|
|
170
|
+
if not context_match(cap, effect_context):
|
|
171
|
+
continue
|
|
172
|
+
current, _ = valid_time(cap, now)
|
|
173
|
+
if not current:
|
|
174
|
+
continue
|
|
175
|
+
entries.append({
|
|
176
|
+
"capability_id": cap["capability_id"],
|
|
177
|
+
"action": cap["action"],
|
|
178
|
+
"decision": cap["decision"],
|
|
179
|
+
"resources": sorted(cap.get("resources", [])),
|
|
180
|
+
"constraints": cap.get("constraints", {}),
|
|
181
|
+
"high_impact": bool(cap.get("high_impact", False)),
|
|
182
|
+
})
|
|
183
|
+
entries.sort(key=lambda x: x["capability_id"])
|
|
184
|
+
semantic = {
|
|
185
|
+
"actor_ref": actor_ref,
|
|
186
|
+
"task_ref": effect_context.get("task_ref"),
|
|
187
|
+
"session_ref": effect_context.get("session_ref"),
|
|
188
|
+
"maintenance_run_ref": effect_context.get("maintenance_run_ref"),
|
|
189
|
+
"entries": entries,
|
|
190
|
+
}
|
|
191
|
+
return {"digest": stable_digest(semantic), **semantic}
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
def authorize(state: dict[str, Any], case_input: dict[str, Any]) -> dict[str, Any]:
|
|
195
|
+
effect = case_input["effect"]
|
|
196
|
+
now = parse_time(case_input["evaluation_time"])
|
|
197
|
+
actor_ref = effect.get("actor_ref")
|
|
198
|
+
|
|
199
|
+
# Persona/prompt/context claims are intentionally ignored for authority.
|
|
200
|
+
if not actor_ref:
|
|
201
|
+
return {
|
|
202
|
+
"case_id": case_input["case_id"],
|
|
203
|
+
"result": "unresolved",
|
|
204
|
+
"reason": "principal_unresolved",
|
|
205
|
+
"matched_capability_refs": [],
|
|
206
|
+
"matched_approval_refs": [],
|
|
207
|
+
"delegation_refs": [],
|
|
208
|
+
"envelope_digest": None,
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
envelope = derive_envelope(state, actor_ref, effect, now)
|
|
212
|
+
candidates = capability_candidates(state, actor_ref, effect, now)
|
|
213
|
+
|
|
214
|
+
current = [x for x in candidates if x["current"]]
|
|
215
|
+
invalid = [x for x in candidates if not x["current"]]
|
|
216
|
+
|
|
217
|
+
denies = [x for x in current if x["capability"]["decision"] == "deny"]
|
|
218
|
+
if denies:
|
|
219
|
+
return {
|
|
220
|
+
"case_id": case_input["case_id"],
|
|
221
|
+
"result": "deny",
|
|
222
|
+
"reason": "explicit_deny",
|
|
223
|
+
"matched_capability_refs": [x["capability"]["capability_id"] for x in denies],
|
|
224
|
+
"matched_approval_refs": [],
|
|
225
|
+
"delegation_refs": sorted({d for x in denies for d in x["delegation_refs"]}),
|
|
226
|
+
"envelope_digest": envelope["digest"],
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
gates = [
|
|
230
|
+
x for x in current
|
|
231
|
+
if x["capability"]["decision"] == "approval_required"
|
|
232
|
+
or (x["capability"]["decision"] == "allow" and x["capability"].get("high_impact", False))
|
|
233
|
+
]
|
|
234
|
+
allows = [x for x in current if x["capability"]["decision"] == "allow"]
|
|
235
|
+
|
|
236
|
+
if gates:
|
|
237
|
+
approved, approval_refs = approval_match(state, actor_ref, effect, now)
|
|
238
|
+
if not approved:
|
|
239
|
+
return {
|
|
240
|
+
"case_id": case_input["case_id"],
|
|
241
|
+
"result": "approval_required",
|
|
242
|
+
"reason": "approval_missing",
|
|
243
|
+
"matched_capability_refs": [x["capability"]["capability_id"] for x in gates],
|
|
244
|
+
"matched_approval_refs": [],
|
|
245
|
+
"delegation_refs": sorted({d for x in gates for d in x["delegation_refs"]}),
|
|
246
|
+
"envelope_digest": envelope["digest"],
|
|
247
|
+
}
|
|
248
|
+
# An approval gate still requires a usable base capability path.
|
|
249
|
+
if not allows and all(x["capability"]["decision"] != "approval_required" for x in gates):
|
|
250
|
+
return {
|
|
251
|
+
"case_id": case_input["case_id"],
|
|
252
|
+
"result": "deny",
|
|
253
|
+
"reason": "no_applicable_allow",
|
|
254
|
+
"matched_capability_refs": [],
|
|
255
|
+
"matched_approval_refs": approval_refs,
|
|
256
|
+
"delegation_refs": [],
|
|
257
|
+
"envelope_digest": envelope["digest"],
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
"case_id": case_input["case_id"],
|
|
261
|
+
"result": "allow",
|
|
262
|
+
"reason": "approved_capability",
|
|
263
|
+
"matched_capability_refs": sorted({
|
|
264
|
+
x["capability"]["capability_id"] for x in (allows + gates)
|
|
265
|
+
}),
|
|
266
|
+
"matched_approval_refs": approval_refs,
|
|
267
|
+
"delegation_refs": sorted({d for x in (allows + gates) for d in x["delegation_refs"]}),
|
|
268
|
+
"envelope_digest": envelope["digest"],
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if allows:
|
|
272
|
+
return {
|
|
273
|
+
"case_id": case_input["case_id"],
|
|
274
|
+
"result": "allow",
|
|
275
|
+
"reason": "allowed_by_capability",
|
|
276
|
+
"matched_capability_refs": [x["capability"]["capability_id"] for x in allows],
|
|
277
|
+
"matched_approval_refs": [],
|
|
278
|
+
"delegation_refs": sorted({d for x in allows for d in x["delegation_refs"]}),
|
|
279
|
+
"envelope_digest": envelope["digest"],
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if invalid:
|
|
283
|
+
reason = invalid[0]["invalid_reason"] or "no_applicable_allow"
|
|
284
|
+
return {
|
|
285
|
+
"case_id": case_input["case_id"],
|
|
286
|
+
"result": "deny",
|
|
287
|
+
"reason": reason,
|
|
288
|
+
"matched_capability_refs": [x["capability"]["capability_id"] for x in invalid],
|
|
289
|
+
"matched_approval_refs": [],
|
|
290
|
+
"delegation_refs": [],
|
|
291
|
+
"envelope_digest": envelope["digest"],
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return {
|
|
295
|
+
"case_id": case_input["case_id"],
|
|
296
|
+
"result": "deny",
|
|
297
|
+
"reason": "no_applicable_allow",
|
|
298
|
+
"matched_capability_refs": [],
|
|
299
|
+
"matched_approval_refs": [],
|
|
300
|
+
"delegation_refs": [],
|
|
301
|
+
"envelope_digest": envelope["digest"],
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
def verify_case(result: dict[str, Any], full_case: dict[str, Any]) -> list[str]:
|
|
306
|
+
expected = full_case["expected"]
|
|
307
|
+
failures = []
|
|
308
|
+
for field in ("result", "reason"):
|
|
309
|
+
if field in expected and result.get(field) != expected[field]:
|
|
310
|
+
failures.append(f"{field} expected {expected[field]!r} got {result.get(field)!r}")
|
|
311
|
+
|
|
312
|
+
if expected.get("delegated") and not result.get("delegation_refs"):
|
|
313
|
+
failures.append("expected delegated authority but no delegation evidence was returned")
|
|
314
|
+
|
|
315
|
+
if expected.get("must_not_allow") and result.get("result") == "allow":
|
|
316
|
+
failures.append("effect expected to remain non-executable but was allowed")
|
|
317
|
+
|
|
318
|
+
return failures
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
def run_all(write_results: bool = False) -> int:
|
|
322
|
+
domains = ["personal", "developer", "company"]
|
|
323
|
+
metrics = {
|
|
324
|
+
"case_count": 0,
|
|
325
|
+
"case_pass_count": 0,
|
|
326
|
+
"allow_count": 0,
|
|
327
|
+
"deny_count": 0,
|
|
328
|
+
"approval_required_count": 0,
|
|
329
|
+
"unresolved_count": 0,
|
|
330
|
+
"deterministic_cases": 0,
|
|
331
|
+
"unauthorized_effects_allowed": 0,
|
|
332
|
+
"prompt_persona_escalations_allowed": 0,
|
|
333
|
+
"delegated_allows": 0,
|
|
334
|
+
"same_actor_multiple_envelopes": 0,
|
|
335
|
+
}
|
|
336
|
+
failures = []
|
|
337
|
+
output_cases = []
|
|
338
|
+
envelope_sets: dict[str, set[str]] = {}
|
|
339
|
+
|
|
340
|
+
for domain in domains:
|
|
341
|
+
fixture = load_json(ROOT / "fixtures" / domain / "authorization-cases.json")
|
|
342
|
+
state = fixture["state"]
|
|
343
|
+
graph = load_json(ROOT / "fixtures" / domain / "graph.json")
|
|
344
|
+
graph_ids = {r["id"] for r in graph}
|
|
345
|
+
|
|
346
|
+
for full_case in fixture["cases"]:
|
|
347
|
+
effect = full_case["effect"]
|
|
348
|
+
# Cross-domain anchor check for existing refs when fixture declares it.
|
|
349
|
+
for ref in full_case.get("must_resolve_refs", []):
|
|
350
|
+
if ref not in graph_ids:
|
|
351
|
+
failures.append(f"{domain}/{full_case['case_id']}: fixture ref not found in domain graph: {ref}")
|
|
352
|
+
|
|
353
|
+
case_input = {k: v for k, v in full_case.items() if k != "expected"}
|
|
354
|
+
first = authorize(state, case_input)
|
|
355
|
+
second = authorize(state, case_input)
|
|
356
|
+
deterministic = stable_digest(first) == stable_digest(second)
|
|
357
|
+
case_failures = verify_case(first, full_case)
|
|
358
|
+
|
|
359
|
+
if not deterministic:
|
|
360
|
+
case_failures.append("repeat evaluation was not deterministic")
|
|
361
|
+
|
|
362
|
+
expected_non_allow = full_case["expected"].get("must_not_allow", False)
|
|
363
|
+
if expected_non_allow and first["result"] == "allow":
|
|
364
|
+
metrics["unauthorized_effects_allowed"] += 1
|
|
365
|
+
|
|
366
|
+
if full_case.get("persona_claim") and first["result"] == "allow" and expected_non_allow:
|
|
367
|
+
metrics["prompt_persona_escalations_allowed"] += 1
|
|
368
|
+
|
|
369
|
+
if first.get("delegation_refs") and first["result"] == "allow":
|
|
370
|
+
metrics["delegated_allows"] += 1
|
|
371
|
+
|
|
372
|
+
actor_ref = effect.get("actor_ref")
|
|
373
|
+
if actor_ref and first.get("envelope_digest"):
|
|
374
|
+
envelope_sets.setdefault(actor_ref, set()).add(first["envelope_digest"])
|
|
375
|
+
|
|
376
|
+
metrics["case_count"] += 1
|
|
377
|
+
metrics[f"{first['result']}_count"] += 1
|
|
378
|
+
metrics["deterministic_cases"] += int(deterministic)
|
|
379
|
+
|
|
380
|
+
if case_failures:
|
|
381
|
+
failures.extend([f"{domain}/{full_case['case_id']}: {x}" for x in case_failures])
|
|
382
|
+
else:
|
|
383
|
+
metrics["case_pass_count"] += 1
|
|
384
|
+
|
|
385
|
+
output_cases.append({
|
|
386
|
+
"domain": domain,
|
|
387
|
+
"result": first,
|
|
388
|
+
"deterministic": deterministic,
|
|
389
|
+
"verification_failures": case_failures,
|
|
390
|
+
})
|
|
391
|
+
|
|
392
|
+
metrics["same_actor_multiple_envelopes"] = sum(1 for v in envelope_sets.values() if len(v) > 1)
|
|
393
|
+
|
|
394
|
+
output = {"policy": POLICY, "metrics": metrics, "failures": failures, "cases": output_cases}
|
|
395
|
+
if write_results:
|
|
396
|
+
(ROOT / "fixtures" / "authorization-results.json").write_text(
|
|
397
|
+
json.dumps(output, indent=2) + "\n"
|
|
398
|
+
)
|
|
399
|
+
|
|
400
|
+
print(json.dumps({"policy": POLICY, "metrics": metrics, "failures": failures}, indent=2))
|
|
401
|
+
|
|
402
|
+
if failures:
|
|
403
|
+
return 1
|
|
404
|
+
if metrics["case_pass_count"] != metrics["case_count"]:
|
|
405
|
+
return 1
|
|
406
|
+
if metrics["unauthorized_effects_allowed"] != 0:
|
|
407
|
+
return 1
|
|
408
|
+
if metrics["prompt_persona_escalations_allowed"] != 0:
|
|
409
|
+
return 1
|
|
410
|
+
if metrics["deterministic_cases"] != metrics["case_count"]:
|
|
411
|
+
return 1
|
|
412
|
+
if metrics["same_actor_multiple_envelopes"] < 1:
|
|
413
|
+
return 1
|
|
414
|
+
if metrics["delegated_allows"] < 1:
|
|
415
|
+
return 1
|
|
416
|
+
return 0
|
|
417
|
+
|
|
418
|
+
|
|
419
|
+
def main() -> int:
|
|
420
|
+
parser = argparse.ArgumentParser()
|
|
421
|
+
parser.add_argument("--write-results", action="store_true")
|
|
422
|
+
args = parser.parse_args()
|
|
423
|
+
return run_all(write_results=args.write_results)
|
|
424
|
+
|
|
425
|
+
|
|
426
|
+
if __name__ == "__main__":
|
|
427
|
+
raise SystemExit(main())
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any
|
|
7
|
+
|
|
8
|
+
from runtime.cosmos_runtime import ObjectiveRequest
|
|
9
|
+
from tools.reference_repository_projection import (
|
|
10
|
+
PROJECT_REF,
|
|
11
|
+
REPOSITORY_REF,
|
|
12
|
+
RepositoryProjection,
|
|
13
|
+
stable_cosmos_ref,
|
|
14
|
+
)
|
|
15
|
+
from tools.reference_self_hosting import COLD_OBJECTIVE
|
|
16
|
+
from tools.reference_self_hosting_environment import (
|
|
17
|
+
SelfHostingRuntime,
|
|
18
|
+
build_self_hosting_runtime,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
COLD_ACTOR_REF = "cosmos:actor:phase9-cold"
|
|
23
|
+
COLD_BINDING_POLICY = {
|
|
24
|
+
"max_hops": 4,
|
|
25
|
+
"max_candidates": 256,
|
|
26
|
+
"max_context_units": 24,
|
|
27
|
+
"minimum_optional_score": 35,
|
|
28
|
+
"required_optional_roles": ["artifact", "history"],
|
|
29
|
+
"require_explicit_anchors": True,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass(frozen=True, slots=True)
|
|
34
|
+
class ColdReconstructionResult:
|
|
35
|
+
objective: str
|
|
36
|
+
current_phase: int
|
|
37
|
+
current_next_task: str | None
|
|
38
|
+
semantic_revision: str
|
|
39
|
+
anchors: tuple[str, ...]
|
|
40
|
+
selected_refs: tuple[str, ...]
|
|
41
|
+
mandatory_expected_refs: tuple[str, ...]
|
|
42
|
+
mandatory_project_state_recall: float
|
|
43
|
+
must_not_bind_governing_violations: int
|
|
44
|
+
binding_status: str
|
|
45
|
+
context_units_used: int
|
|
46
|
+
context_units_available: int
|
|
47
|
+
binding_record: dict[str, Any]
|
|
48
|
+
selected_records: tuple[dict[str, Any], ...]
|
|
49
|
+
narrow_follow_up_count: int
|
|
50
|
+
narrow_follow_up_refs: tuple[str, ...]
|
|
51
|
+
|
|
52
|
+
def to_dict(self) -> dict[str, Any]:
|
|
53
|
+
return {
|
|
54
|
+
"objective": self.objective,
|
|
55
|
+
"current_phase": self.current_phase,
|
|
56
|
+
"current_next_task": self.current_next_task,
|
|
57
|
+
"semantic_revision": self.semantic_revision,
|
|
58
|
+
"anchors": list(self.anchors),
|
|
59
|
+
"selected_refs": list(self.selected_refs),
|
|
60
|
+
"mandatory_expected_refs": list(self.mandatory_expected_refs),
|
|
61
|
+
"mandatory_project_state_recall": self.mandatory_project_state_recall,
|
|
62
|
+
"must_not_bind_governing_violations": self.must_not_bind_governing_violations,
|
|
63
|
+
"binding_status": self.binding_status,
|
|
64
|
+
"context_units_used": self.context_units_used,
|
|
65
|
+
"context_units_available": self.context_units_available,
|
|
66
|
+
"narrow_follow_up_count": self.narrow_follow_up_count,
|
|
67
|
+
"narrow_follow_up_refs": list(self.narrow_follow_up_refs),
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def _node_map(projection: RepositoryProjection) -> dict[str, dict[str, Any]]:
|
|
72
|
+
return {
|
|
73
|
+
record["id"]: record
|
|
74
|
+
for record in projection.graph
|
|
75
|
+
if record.get("record_type") == "node"
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def resolve_cold_anchors(projection: RepositoryProjection) -> tuple[str, ...]:
|
|
80
|
+
if projection.current_phase <= 0:
|
|
81
|
+
raise ValueError("projection has no current phase")
|
|
82
|
+
refs = [
|
|
83
|
+
PROJECT_REF,
|
|
84
|
+
REPOSITORY_REF,
|
|
85
|
+
stable_cosmos_ref(f"phase:{projection.current_phase}"),
|
|
86
|
+
stable_cosmos_ref("repository:recent-changes"),
|
|
87
|
+
]
|
|
88
|
+
if projection.current_next_task:
|
|
89
|
+
refs.append(stable_cosmos_ref(f"task:{projection.current_next_task}"))
|
|
90
|
+
nodes = _node_map(projection)
|
|
91
|
+
missing = [ref for ref in refs if ref not in nodes]
|
|
92
|
+
if missing:
|
|
93
|
+
raise ValueError("cold reconstruction anchors do not resolve: " + ", ".join(missing))
|
|
94
|
+
return tuple(refs)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def mandatory_project_refs(
|
|
98
|
+
projection: RepositoryProjection,
|
|
99
|
+
anchors: tuple[str, ...],
|
|
100
|
+
) -> tuple[str, ...]:
|
|
101
|
+
nodes = _node_map(projection)
|
|
102
|
+
expected = set(anchors)
|
|
103
|
+
governing_sources = {
|
|
104
|
+
PROJECT_REF,
|
|
105
|
+
stable_cosmos_ref(f"phase:{projection.current_phase}"),
|
|
106
|
+
}
|
|
107
|
+
for record in projection.graph:
|
|
108
|
+
if record.get("record_type") != "edge":
|
|
109
|
+
continue
|
|
110
|
+
if record.get("relation_type") != "core.governed_by":
|
|
111
|
+
continue
|
|
112
|
+
if record.get("source") not in governing_sources:
|
|
113
|
+
continue
|
|
114
|
+
target = record.get("target")
|
|
115
|
+
node = nodes.get(target)
|
|
116
|
+
if node and node.get("lifecycle_state") == "active":
|
|
117
|
+
expected.add(target)
|
|
118
|
+
return tuple(sorted(expected))
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def _selected_trace_is_explainable(binding_record: dict[str, Any]) -> bool:
|
|
122
|
+
selected = set((binding_record.get("selection") or {}).get("mandatory_selected", []))
|
|
123
|
+
selected.update((binding_record.get("selection") or {}).get("optional_selected", []))
|
|
124
|
+
mandatory = {
|
|
125
|
+
item["candidate_ref"]
|
|
126
|
+
for item in binding_record.get("mandatory_classification", [])
|
|
127
|
+
if item.get("mandatory")
|
|
128
|
+
}
|
|
129
|
+
scored = {
|
|
130
|
+
item["ref"]
|
|
131
|
+
for item in binding_record.get("optional_scores", [])
|
|
132
|
+
}
|
|
133
|
+
discovered = {
|
|
134
|
+
item["record_ref"]
|
|
135
|
+
for item in (binding_record.get("discovery") or {}).get("candidates", [])
|
|
136
|
+
}
|
|
137
|
+
return selected.issubset(discovered) and selected.issubset(mandatory | scored)
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def _empty_authority_state(_episode_id: str) -> dict[str, Any]:
|
|
141
|
+
return {"capabilities": [], "approvals": [], "delegations": []}
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def run_cold_reconstruction(
|
|
145
|
+
*,
|
|
146
|
+
database_path: Path | str,
|
|
147
|
+
root: Path | None = None,
|
|
148
|
+
) -> ColdReconstructionResult:
|
|
149
|
+
runtime = build_self_hosting_runtime(
|
|
150
|
+
database_path=database_path,
|
|
151
|
+
authority_state_provider=_empty_authority_state,
|
|
152
|
+
root=root,
|
|
153
|
+
)
|
|
154
|
+
projection = runtime.environment.projection
|
|
155
|
+
anchors = resolve_cold_anchors(projection)
|
|
156
|
+
|
|
157
|
+
intake = runtime.intake_objective(ObjectiveRequest(
|
|
158
|
+
objective=COLD_OBJECTIVE,
|
|
159
|
+
requester_ref=COLD_ACTOR_REF,
|
|
160
|
+
execution_actor_ref=COLD_ACTOR_REF,
|
|
161
|
+
environment_ref=runtime.environment.environment_id,
|
|
162
|
+
environment_revision=runtime.environment.semantic_revision,
|
|
163
|
+
scope_refs=list(anchors),
|
|
164
|
+
idempotency_key=f"phase9:cold:{runtime.environment.semantic_revision}",
|
|
165
|
+
metadata={"cold_start": True},
|
|
166
|
+
))
|
|
167
|
+
bound = runtime.bind_context(
|
|
168
|
+
episode_id=intake.episode_id,
|
|
169
|
+
binding_options=dict(COLD_BINDING_POLICY),
|
|
170
|
+
)
|
|
171
|
+
snapshot = runtime.services.store.get_latest_binding(intake.episode_id)
|
|
172
|
+
if snapshot is None:
|
|
173
|
+
raise RuntimeError("cold binding snapshot was not persisted")
|
|
174
|
+
binding_record = snapshot["binding_record"]
|
|
175
|
+
if not _selected_trace_is_explainable(binding_record):
|
|
176
|
+
raise RuntimeError("Binding Record does not explain every selected item")
|
|
177
|
+
|
|
178
|
+
selected_records = tuple(bound.context_records)
|
|
179
|
+
selected_refs = tuple(record["id"] for record in selected_records)
|
|
180
|
+
expected_refs = mandatory_project_refs(projection, anchors)
|
|
181
|
+
present = len(set(expected_refs) & set(selected_refs))
|
|
182
|
+
recall = present / len(expected_refs) if expected_refs else 1.0
|
|
183
|
+
|
|
184
|
+
violations = sum(
|
|
185
|
+
1
|
|
186
|
+
for item in bound.context_bundle["items"]
|
|
187
|
+
if item["role"] == "governing"
|
|
188
|
+
and _node_map(projection).get(item["source_ref"], {}).get("lifecycle_state")
|
|
189
|
+
in {"stale", "superseded"}
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
if projection.current_next_task:
|
|
193
|
+
narrow_refs = [stable_cosmos_ref(f"task:{projection.current_next_task}")]
|
|
194
|
+
narrow_objective = "Inspect the current approved Cosmos task definition"
|
|
195
|
+
narrow_required_optional_roles = ["artifact"]
|
|
196
|
+
narrow_max_hops = 1
|
|
197
|
+
else:
|
|
198
|
+
narrow_refs = [
|
|
199
|
+
stable_cosmos_ref(f"phase:{projection.current_phase}"),
|
|
200
|
+
stable_cosmos_ref("artifact:docs/ROADMAP.md"),
|
|
201
|
+
]
|
|
202
|
+
narrow_objective = "Inspect the completed Cosmos roadmap state"
|
|
203
|
+
narrow_required_optional_roles = []
|
|
204
|
+
narrow_max_hops = 1
|
|
205
|
+
narrow = runtime.intake_objective(ObjectiveRequest(
|
|
206
|
+
objective=narrow_objective,
|
|
207
|
+
requester_ref=COLD_ACTOR_REF,
|
|
208
|
+
execution_actor_ref=COLD_ACTOR_REF,
|
|
209
|
+
environment_ref=runtime.environment.environment_id,
|
|
210
|
+
environment_revision=runtime.environment.semantic_revision,
|
|
211
|
+
scope_refs=narrow_refs,
|
|
212
|
+
idempotency_key=f"phase9:narrow:{runtime.environment.semantic_revision}",
|
|
213
|
+
metadata={"cold_start": True, "follow_up": True, "terminal": projection.current_next_task is None},
|
|
214
|
+
))
|
|
215
|
+
narrow_bound = runtime.bind_context(
|
|
216
|
+
episode_id=narrow.episode_id,
|
|
217
|
+
binding_options={
|
|
218
|
+
"max_hops": narrow_max_hops,
|
|
219
|
+
"max_candidates": 64,
|
|
220
|
+
"max_context_units": 8,
|
|
221
|
+
"minimum_optional_score": 35,
|
|
222
|
+
"required_optional_roles": narrow_required_optional_roles,
|
|
223
|
+
"require_explicit_anchors": True,
|
|
224
|
+
},
|
|
225
|
+
)
|
|
226
|
+
|
|
227
|
+
selection = binding_record["selection"]
|
|
228
|
+
return ColdReconstructionResult(
|
|
229
|
+
objective=COLD_OBJECTIVE,
|
|
230
|
+
current_phase=projection.current_phase,
|
|
231
|
+
current_next_task=projection.current_next_task,
|
|
232
|
+
semantic_revision=runtime.environment.semantic_revision,
|
|
233
|
+
anchors=anchors,
|
|
234
|
+
selected_refs=selected_refs,
|
|
235
|
+
mandatory_expected_refs=expected_refs,
|
|
236
|
+
mandatory_project_state_recall=recall,
|
|
237
|
+
must_not_bind_governing_violations=violations,
|
|
238
|
+
binding_status=binding_record["status"],
|
|
239
|
+
context_units_used=selection["context_units_used"],
|
|
240
|
+
context_units_available=selection["context_units_available"],
|
|
241
|
+
binding_record=binding_record,
|
|
242
|
+
selected_records=selected_records,
|
|
243
|
+
narrow_follow_up_count=len(narrow_bound.context_records),
|
|
244
|
+
narrow_follow_up_refs=tuple(record["id"] for record in narrow_bound.context_records),
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def main() -> int:
|
|
249
|
+
import tempfile
|
|
250
|
+
|
|
251
|
+
with tempfile.TemporaryDirectory(prefix="cosmos-p9-cold-", ignore_cleanup_errors=True) as temp:
|
|
252
|
+
result = run_cold_reconstruction(
|
|
253
|
+
database_path=Path(temp) / "runtime.sqlite3",
|
|
254
|
+
)
|
|
255
|
+
print(json.dumps(result.to_dict(), indent=2, sort_keys=True))
|
|
256
|
+
return 0 if (
|
|
257
|
+
result.objective == COLD_OBJECTIVE
|
|
258
|
+
and result.mandatory_project_state_recall == 1.0
|
|
259
|
+
and result.must_not_bind_governing_violations == 0
|
|
260
|
+
) else 1
|
|
261
|
+
|
|
262
|
+
|
|
263
|
+
if __name__ == "__main__":
|
|
264
|
+
raise SystemExit(main())
|