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,506 @@
|
|
|
1
|
+
"""Cosmos Certification Ledger & Lifecycle Engine (HYG-001).
|
|
2
|
+
|
|
3
|
+
Implements the cosmos.certification/1 contract per spec/hygiene/COSMOS-CERTIFICATION-CONTRACT.md.
|
|
4
|
+
Persists durable, hash-chained certification attestations in .cosmos/certifications/ledger.jsonl.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import hashlib
|
|
10
|
+
import json
|
|
11
|
+
import os
|
|
12
|
+
import sys as _cosmos_sys
|
|
13
|
+
import pathlib as _cosmos_pathlib
|
|
14
|
+
_cosmos_root = str(_cosmos_pathlib.Path(__file__).resolve().parents[1]) # the file can run as a script from any folder
|
|
15
|
+
if _cosmos_root not in _cosmos_sys.path:
|
|
16
|
+
_cosmos_sys.path.insert(0, _cosmos_root)
|
|
17
|
+
from tools import cosmos_proc as subprocess
|
|
18
|
+
from dataclasses import asdict, dataclass, field
|
|
19
|
+
from datetime import datetime, timezone
|
|
20
|
+
from pathlib import Path
|
|
21
|
+
from typing import Any, Literal
|
|
22
|
+
|
|
23
|
+
ROOT = Path(__file__).resolve().parents[1]
|
|
24
|
+
DEFAULT_LEDGER_PATH = ROOT / ".cosmos" / "certifications" / "ledger.jsonl"
|
|
25
|
+
|
|
26
|
+
CertificateState = Literal["VALID", "STALE", "REVOKED"]
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
@dataclass(frozen=True)
|
|
30
|
+
class CosmosCertificate:
|
|
31
|
+
schema: str
|
|
32
|
+
certificate_id: str
|
|
33
|
+
component_ref: str
|
|
34
|
+
state: CertificateState
|
|
35
|
+
certified_at: str
|
|
36
|
+
certified_commit: str
|
|
37
|
+
certified_tree_digest: str
|
|
38
|
+
dependencies: tuple[str, ...]
|
|
39
|
+
evidence_refs: tuple[str, ...]
|
|
40
|
+
verifier: str
|
|
41
|
+
certificate_digest: str
|
|
42
|
+
stale_reason: str | None = None
|
|
43
|
+
previous_chain_digest: str | None = None
|
|
44
|
+
chain_digest: str | None = None
|
|
45
|
+
|
|
46
|
+
def to_dict(self) -> dict[str, Any]:
|
|
47
|
+
return {
|
|
48
|
+
"schema": self.schema,
|
|
49
|
+
"certificate_id": self.certificate_id,
|
|
50
|
+
"component_ref": self.component_ref,
|
|
51
|
+
"state": self.state,
|
|
52
|
+
"certified_at": self.certified_at,
|
|
53
|
+
"certified_commit": self.certified_commit,
|
|
54
|
+
"certified_tree_digest": self.certified_tree_digest,
|
|
55
|
+
"dependencies": list(self.dependencies),
|
|
56
|
+
"evidence_refs": list(self.evidence_refs),
|
|
57
|
+
"verifier": self.verifier,
|
|
58
|
+
"stale_reason": self.stale_reason,
|
|
59
|
+
"certificate_digest": self.certificate_digest,
|
|
60
|
+
"previous_chain_digest": self.previous_chain_digest,
|
|
61
|
+
"chain_digest": self.chain_digest,
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def compute_canonical_digest(data: dict[str, Any]) -> str:
|
|
66
|
+
"""Computes deterministic SHA-256 over canonical JSON representation."""
|
|
67
|
+
canonical_bytes = json.dumps(data, sort_keys=True, separators=(",", ":")).encode("utf-8")
|
|
68
|
+
return f"sha256:{hashlib.sha256(canonical_bytes).hexdigest()}"
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def compute_file_sha256(path: Path) -> str:
|
|
72
|
+
if not path.is_file():
|
|
73
|
+
return "missing"
|
|
74
|
+
digest = hashlib.sha256()
|
|
75
|
+
with open(path, "rb") as f:
|
|
76
|
+
for chunk in iter(lambda: f.read(1024 * 1024), b""):
|
|
77
|
+
digest.update(chunk)
|
|
78
|
+
return f"sha256:{digest.hexdigest()}"
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
# W1.02: bounded git children — a hung git must never bind a certification to
|
|
82
|
+
# a default fallback value (loud failure, never silent default).
|
|
83
|
+
GIT_TIMEOUT = 60
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def get_current_git_commit(root: Path = ROOT) -> str:
|
|
87
|
+
try:
|
|
88
|
+
res = subprocess.run(
|
|
89
|
+
["git", "-C", str(root), "rev-parse", "HEAD"],
|
|
90
|
+
check=True, capture_output=True, text=True, timeout=GIT_TIMEOUT,
|
|
91
|
+
)
|
|
92
|
+
return res.stdout.strip()
|
|
93
|
+
except subprocess.TimeoutExpired:
|
|
94
|
+
raise
|
|
95
|
+
except Exception:
|
|
96
|
+
return "unknown-commit"
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
def get_current_tree_digest(root: Path = ROOT) -> str:
|
|
100
|
+
try:
|
|
101
|
+
res = subprocess.run(
|
|
102
|
+
["git", "-C", str(root), "rev-parse", "HEAD^{tree}"],
|
|
103
|
+
check=True, capture_output=True, text=True, timeout=GIT_TIMEOUT,
|
|
104
|
+
)
|
|
105
|
+
tree_sha = res.stdout.strip()
|
|
106
|
+
return f"sha256:{hashlib.sha256(tree_sha.encode('utf-8')).hexdigest()}"
|
|
107
|
+
except subprocess.TimeoutExpired:
|
|
108
|
+
raise
|
|
109
|
+
except Exception:
|
|
110
|
+
return f"sha256:{hashlib.sha256(b'unknown-tree').hexdigest()}"
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
class CertificationLedger:
|
|
114
|
+
"""Manages append-only, tamper-evident storage of component certifications."""
|
|
115
|
+
|
|
116
|
+
def __init__(self, ledger_path: Path | None = None, repo_root: Path = ROOT):
|
|
117
|
+
self.ledger_path = (ledger_path or DEFAULT_LEDGER_PATH).resolve()
|
|
118
|
+
self.repo_root = repo_root.resolve()
|
|
119
|
+
self.ledger_path.parent.mkdir(parents=True, exist_ok=True)
|
|
120
|
+
|
|
121
|
+
def _get_last_chain_digest(self) -> str | None:
|
|
122
|
+
if not self.ledger_path.is_file():
|
|
123
|
+
return None
|
|
124
|
+
last_digest = None
|
|
125
|
+
with open(self.ledger_path, "r", encoding="utf-8") as f:
|
|
126
|
+
for line in f:
|
|
127
|
+
line = line.strip()
|
|
128
|
+
if line:
|
|
129
|
+
try:
|
|
130
|
+
record = json.loads(line)
|
|
131
|
+
last_digest = record.get("chain_digest")
|
|
132
|
+
except Exception:
|
|
133
|
+
pass
|
|
134
|
+
return last_digest
|
|
135
|
+
|
|
136
|
+
def issue_certificate(
|
|
137
|
+
self,
|
|
138
|
+
component_ref: str,
|
|
139
|
+
dependencies: list[str],
|
|
140
|
+
evidence_refs: list[str],
|
|
141
|
+
verifier: str = "hygiene:deterministic-runner",
|
|
142
|
+
commit: str | None = None,
|
|
143
|
+
tree_digest: str | None = None,
|
|
144
|
+
) -> CosmosCertificate:
|
|
145
|
+
"""Issues a new VALID certificate and appends it to the durable chain."""
|
|
146
|
+
commit_id = commit or get_current_git_commit(self.repo_root)
|
|
147
|
+
tree_id = tree_digest or get_current_tree_digest(self.repo_root)
|
|
148
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
149
|
+
cert_id = f"cert:{component_ref.replace('cosmos:', '').replace(':', '-')}"
|
|
150
|
+
|
|
151
|
+
payload_to_hash = {
|
|
152
|
+
"schema": "cosmos.certification/1",
|
|
153
|
+
"certificate_id": cert_id,
|
|
154
|
+
"component_ref": component_ref,
|
|
155
|
+
"state": "VALID",
|
|
156
|
+
"certified_at": now,
|
|
157
|
+
"certified_commit": commit_id,
|
|
158
|
+
"certified_tree_digest": tree_id,
|
|
159
|
+
"dependencies": sorted(dependencies),
|
|
160
|
+
"evidence_refs": sorted(evidence_refs),
|
|
161
|
+
"verifier": verifier,
|
|
162
|
+
"stale_reason": None,
|
|
163
|
+
}
|
|
164
|
+
cert_digest = compute_canonical_digest(payload_to_hash)
|
|
165
|
+
|
|
166
|
+
prev_chain = self._get_last_chain_digest()
|
|
167
|
+
chain_input = f"{prev_chain or 'root'}::{cert_digest}".encode("utf-8")
|
|
168
|
+
chain_digest = f"sha256:{hashlib.sha256(chain_input).hexdigest()}"
|
|
169
|
+
|
|
170
|
+
cert = CosmosCertificate(
|
|
171
|
+
schema="cosmos.certification/1",
|
|
172
|
+
certificate_id=cert_id,
|
|
173
|
+
component_ref=component_ref,
|
|
174
|
+
state="VALID",
|
|
175
|
+
certified_at=now,
|
|
176
|
+
certified_commit=commit_id,
|
|
177
|
+
certified_tree_digest=tree_id,
|
|
178
|
+
dependencies=tuple(sorted(dependencies)),
|
|
179
|
+
evidence_refs=tuple(sorted(evidence_refs)),
|
|
180
|
+
verifier=verifier,
|
|
181
|
+
certificate_digest=cert_digest,
|
|
182
|
+
stale_reason=None,
|
|
183
|
+
previous_chain_digest=prev_chain,
|
|
184
|
+
chain_digest=chain_digest,
|
|
185
|
+
)
|
|
186
|
+
|
|
187
|
+
with open(self.ledger_path, "a", encoding="utf-8") as f:
|
|
188
|
+
f.write(json.dumps(cert.to_dict()) + "\n")
|
|
189
|
+
|
|
190
|
+
return cert
|
|
191
|
+
|
|
192
|
+
def update_certificate_state(
|
|
193
|
+
self,
|
|
194
|
+
component_ref: str,
|
|
195
|
+
new_state: CertificateState,
|
|
196
|
+
reason: str | None = None,
|
|
197
|
+
verifier: str = "hygiene:invalidation-engine",
|
|
198
|
+
) -> CosmosCertificate:
|
|
199
|
+
"""Appends a state transition record (STALE or REVOKED) for a certificate."""
|
|
200
|
+
current = self.get_latest_certificate(component_ref)
|
|
201
|
+
if not current:
|
|
202
|
+
raise ValueError(f"No existing certificate found for {component_ref}")
|
|
203
|
+
|
|
204
|
+
commit_id = get_current_git_commit(self.repo_root)
|
|
205
|
+
tree_id = get_current_tree_digest(self.repo_root)
|
|
206
|
+
now = datetime.now(timezone.utc).isoformat()
|
|
207
|
+
|
|
208
|
+
payload_to_hash = {
|
|
209
|
+
"schema": "cosmos.certification/1",
|
|
210
|
+
"certificate_id": current.certificate_id,
|
|
211
|
+
"component_ref": component_ref,
|
|
212
|
+
"state": new_state,
|
|
213
|
+
"certified_at": now,
|
|
214
|
+
"certified_commit": commit_id,
|
|
215
|
+
"certified_tree_digest": tree_id,
|
|
216
|
+
"dependencies": list(current.dependencies),
|
|
217
|
+
"evidence_refs": list(current.evidence_refs),
|
|
218
|
+
"verifier": verifier,
|
|
219
|
+
"stale_reason": reason,
|
|
220
|
+
}
|
|
221
|
+
cert_digest = compute_canonical_digest(payload_to_hash)
|
|
222
|
+
|
|
223
|
+
prev_chain = self._get_last_chain_digest()
|
|
224
|
+
chain_input = f"{prev_chain or 'root'}::{cert_digest}".encode("utf-8")
|
|
225
|
+
chain_digest = f"sha256:{hashlib.sha256(chain_input).hexdigest()}"
|
|
226
|
+
|
|
227
|
+
cert = CosmosCertificate(
|
|
228
|
+
schema="cosmos.certification/1",
|
|
229
|
+
certificate_id=current.certificate_id,
|
|
230
|
+
component_ref=component_ref,
|
|
231
|
+
state=new_state,
|
|
232
|
+
certified_at=now,
|
|
233
|
+
certified_commit=commit_id,
|
|
234
|
+
certified_tree_digest=tree_id,
|
|
235
|
+
dependencies=current.dependencies,
|
|
236
|
+
evidence_refs=current.evidence_refs,
|
|
237
|
+
verifier=verifier,
|
|
238
|
+
certificate_digest=cert_digest,
|
|
239
|
+
stale_reason=reason,
|
|
240
|
+
previous_chain_digest=prev_chain,
|
|
241
|
+
chain_digest=chain_digest,
|
|
242
|
+
)
|
|
243
|
+
|
|
244
|
+
with open(self.ledger_path, "a", encoding="utf-8") as f:
|
|
245
|
+
f.write(json.dumps(cert.to_dict()) + "\n")
|
|
246
|
+
|
|
247
|
+
return cert
|
|
248
|
+
|
|
249
|
+
def get_latest_certificate(self, component_ref: str) -> CosmosCertificate | None:
|
|
250
|
+
latest = None
|
|
251
|
+
for cert in self.list_all_records():
|
|
252
|
+
if cert.component_ref == component_ref or cert.certificate_id == component_ref:
|
|
253
|
+
latest = cert
|
|
254
|
+
return latest
|
|
255
|
+
|
|
256
|
+
def list_all_records(self) -> list[CosmosCertificate]:
|
|
257
|
+
if not self.ledger_path.is_file():
|
|
258
|
+
return []
|
|
259
|
+
records = []
|
|
260
|
+
with open(self.ledger_path, "r", encoding="utf-8") as f:
|
|
261
|
+
for line in f:
|
|
262
|
+
line = line.strip()
|
|
263
|
+
if line:
|
|
264
|
+
d = json.loads(line)
|
|
265
|
+
records.append(
|
|
266
|
+
CosmosCertificate(
|
|
267
|
+
schema=d["schema"],
|
|
268
|
+
certificate_id=d["certificate_id"],
|
|
269
|
+
component_ref=d["component_ref"],
|
|
270
|
+
state=d["state"],
|
|
271
|
+
certified_at=d["certified_at"],
|
|
272
|
+
certified_commit=d["certified_commit"],
|
|
273
|
+
certified_tree_digest=d["certified_tree_digest"],
|
|
274
|
+
dependencies=tuple(d.get("dependencies", ())),
|
|
275
|
+
evidence_refs=tuple(d.get("evidence_refs", ())),
|
|
276
|
+
verifier=d.get("verifier", "unknown"),
|
|
277
|
+
certificate_digest=d["certificate_digest"],
|
|
278
|
+
stale_reason=d.get("stale_reason"),
|
|
279
|
+
previous_chain_digest=d.get("previous_chain_digest"),
|
|
280
|
+
chain_digest=d.get("chain_digest"),
|
|
281
|
+
)
|
|
282
|
+
)
|
|
283
|
+
return records
|
|
284
|
+
def get_active_certificates(self) -> dict[str, CosmosCertificate]:
|
|
285
|
+
"""Returns map of component_ref -> latest certificate."""
|
|
286
|
+
active = {}
|
|
287
|
+
for cert in self.list_all_records():
|
|
288
|
+
active[cert.component_ref] = cert
|
|
289
|
+
return active
|
|
290
|
+
|
|
291
|
+
def verify_ledger_integrity(self) -> dict[str, Any]:
|
|
292
|
+
"""Verifies the cryptographic chain and individual certificate digests."""
|
|
293
|
+
records = self.list_all_records()
|
|
294
|
+
if not records:
|
|
295
|
+
return {"valid": True, "count": 0, "errors": []}
|
|
296
|
+
|
|
297
|
+
errors = []
|
|
298
|
+
expected_prev = None
|
|
299
|
+
|
|
300
|
+
for idx, cert in enumerate(records):
|
|
301
|
+
if cert.previous_chain_digest != expected_prev:
|
|
302
|
+
errors.append(
|
|
303
|
+
f"Record {idx} ({cert.certificate_id}): chain break. "
|
|
304
|
+
f"Expected previous {expected_prev}, got {cert.previous_chain_digest}"
|
|
305
|
+
)
|
|
306
|
+
|
|
307
|
+
payload = {
|
|
308
|
+
"schema": cert.schema,
|
|
309
|
+
"certificate_id": cert.certificate_id,
|
|
310
|
+
"component_ref": cert.component_ref,
|
|
311
|
+
"state": cert.state,
|
|
312
|
+
"certified_at": cert.certified_at,
|
|
313
|
+
"certified_commit": cert.certified_commit,
|
|
314
|
+
"certified_tree_digest": cert.certified_tree_digest,
|
|
315
|
+
"dependencies": sorted(cert.dependencies),
|
|
316
|
+
"evidence_refs": sorted(cert.evidence_refs),
|
|
317
|
+
"verifier": cert.verifier,
|
|
318
|
+
"stale_reason": cert.stale_reason,
|
|
319
|
+
}
|
|
320
|
+
computed_cert_digest = compute_canonical_digest(payload)
|
|
321
|
+
if computed_cert_digest != cert.certificate_digest:
|
|
322
|
+
errors.append(
|
|
323
|
+
f"Record {idx} ({cert.certificate_id}): digest mismatch. "
|
|
324
|
+
f"Computed {computed_cert_digest}, recorded {cert.certificate_digest}"
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
chain_input = f"{cert.previous_chain_digest or 'root'}::{cert.certificate_digest}".encode("utf-8")
|
|
328
|
+
computed_chain = f"sha256:{hashlib.sha256(chain_input).hexdigest()}"
|
|
329
|
+
if computed_chain != cert.chain_digest:
|
|
330
|
+
errors.append(
|
|
331
|
+
f"Record {idx} ({cert.certificate_id}): chain digest mismatch. "
|
|
332
|
+
f"Computed {computed_chain}, recorded {cert.chain_digest}"
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
expected_prev = cert.chain_digest
|
|
336
|
+
|
|
337
|
+
return {
|
|
338
|
+
"valid": len(errors) == 0,
|
|
339
|
+
"count": len(records),
|
|
340
|
+
"errors": errors,
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
|
|
345
|
+
def recertify_component(
|
|
346
|
+
ledger: CertificationLedger,
|
|
347
|
+
component_ref: str,
|
|
348
|
+
verifier: str = "hygiene:recertification-runner",
|
|
349
|
+
) -> CosmosCertificate:
|
|
350
|
+
"""Re-verifies and issues a new VALID certificate for an existing component."""
|
|
351
|
+
active = ledger.get_active_certificates()
|
|
352
|
+
current = active.get(component_ref)
|
|
353
|
+
if not current:
|
|
354
|
+
raise ValueError(f"Cannot recertify unknown component: {component_ref}")
|
|
355
|
+
|
|
356
|
+
return ledger.issue_certificate(
|
|
357
|
+
component_ref=component_ref,
|
|
358
|
+
dependencies=list(current.dependencies),
|
|
359
|
+
evidence_refs=list(current.evidence_refs),
|
|
360
|
+
verifier=verifier,
|
|
361
|
+
)
|
|
362
|
+
|
|
363
|
+
|
|
364
|
+
def seed_baseline_certifications(ledger: CertificationLedger) -> list[CosmosCertificate]:
|
|
365
|
+
"""Issues initial baseline certificates for canonical Cosmos platform components if missing."""
|
|
366
|
+
baseline_specs = [
|
|
367
|
+
{
|
|
368
|
+
"component_ref": "cosmos:component:core-runtime",
|
|
369
|
+
"dependencies": [
|
|
370
|
+
"runtime/cosmos_runtime/actors.py",
|
|
371
|
+
"runtime/cosmos_runtime/authorization.py",
|
|
372
|
+
"runtime/cosmos_runtime/context.py",
|
|
373
|
+
"runtime/cosmos_runtime/continuation.py",
|
|
374
|
+
"runtime/cosmos_runtime/effects.py",
|
|
375
|
+
"runtime/cosmos_runtime/intake.py",
|
|
376
|
+
"runtime/cosmos_runtime/resilience.py",
|
|
377
|
+
"runtime/cosmos_runtime/store.py",
|
|
378
|
+
],
|
|
379
|
+
"evidence_refs": [
|
|
380
|
+
"runtime/tests/test_runtime_conformance.py",
|
|
381
|
+
"runtime/tests/test_authorization_gateway.py",
|
|
382
|
+
],
|
|
383
|
+
"verifier": "hygiene:baseline-conformance",
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
"component_ref": "cosmos:component:ontology",
|
|
387
|
+
"dependencies": [
|
|
388
|
+
"tools/validate_ontology.py",
|
|
389
|
+
],
|
|
390
|
+
"evidence_refs": [
|
|
391
|
+
"runtime/tests/test_cosmos15_baseline.py",
|
|
392
|
+
],
|
|
393
|
+
"verifier": "hygiene:ontology-verifier",
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
"component_ref": "cosmos:component:schema-integrity",
|
|
397
|
+
"dependencies": [
|
|
398
|
+
"tools/schemas/cosmos-record.schema.json",
|
|
399
|
+
"tools/schemas/relation-type.schema.json",
|
|
400
|
+
"tools/schemas/cosmos-certification.schema.json",
|
|
401
|
+
],
|
|
402
|
+
"evidence_refs": [
|
|
403
|
+
"runtime/tests/test_cosmos_hygiene.py",
|
|
404
|
+
],
|
|
405
|
+
"verifier": "hygiene:schema-validator",
|
|
406
|
+
},
|
|
407
|
+
{
|
|
408
|
+
"component_ref": "cosmos:component:delta-attribution",
|
|
409
|
+
"dependencies": [
|
|
410
|
+
"tools/cosmos_delta.py",
|
|
411
|
+
],
|
|
412
|
+
"evidence_refs": [
|
|
413
|
+
"runtime/tests/test_cosmos_delta.py",
|
|
414
|
+
],
|
|
415
|
+
"verifier": "hygiene:delta-evaluator",
|
|
416
|
+
},
|
|
417
|
+
{
|
|
418
|
+
"component_ref": "cosmos:component:hygiene-certification",
|
|
419
|
+
"dependencies": [
|
|
420
|
+
"tools/cosmos_hygiene.py",
|
|
421
|
+
"tools/cosmos_certification.py",
|
|
422
|
+
],
|
|
423
|
+
"evidence_refs": [
|
|
424
|
+
"runtime/tests/test_cosmos_certification.py",
|
|
425
|
+
"runtime/tests/test_cosmos_hygiene.py",
|
|
426
|
+
],
|
|
427
|
+
"verifier": "hygiene:deterministic-runner",
|
|
428
|
+
},
|
|
429
|
+
]
|
|
430
|
+
|
|
431
|
+
active = ledger.get_active_certificates()
|
|
432
|
+
issued: list[CosmosCertificate] = []
|
|
433
|
+
|
|
434
|
+
for spec in baseline_specs:
|
|
435
|
+
ref = spec["component_ref"]
|
|
436
|
+
# Only seed if no active certificate exists for this component
|
|
437
|
+
if ref not in active:
|
|
438
|
+
cert = ledger.issue_certificate(
|
|
439
|
+
component_ref=ref,
|
|
440
|
+
dependencies=spec["dependencies"],
|
|
441
|
+
evidence_refs=spec["evidence_refs"],
|
|
442
|
+
verifier=spec["verifier"],
|
|
443
|
+
)
|
|
444
|
+
issued.append(cert)
|
|
445
|
+
|
|
446
|
+
return issued
|
|
447
|
+
|
|
448
|
+
|
|
449
|
+
def main(argv: list[str] | None = None) -> int:
|
|
450
|
+
import argparse
|
|
451
|
+
|
|
452
|
+
parser = argparse.ArgumentParser(description="Cosmos Certification Ledger CLI")
|
|
453
|
+
parser.add_argument("--seed", action="store_true", help="Seed baseline canonical component certificates")
|
|
454
|
+
parser.add_argument("--recertify", type=str, default=None, help="Recertify a specific component (e.g. cosmos:component:core-runtime)")
|
|
455
|
+
parser.add_argument("--verify", action="store_true", help="Verify cryptographic chain integrity")
|
|
456
|
+
parser.add_argument("--status", action="store_true", help="Show active certificate states")
|
|
457
|
+
parser.add_argument("--json", action="store_true", help="Output status/verification as JSON")
|
|
458
|
+
parser.add_argument("--ledger", type=Path, default=None, help="Path to ledger.jsonl")
|
|
459
|
+
parser.add_argument("--root", type=Path, default=ROOT, help="Repository root path")
|
|
460
|
+
|
|
461
|
+
args = parser.parse_args(argv)
|
|
462
|
+
ledger = CertificationLedger(ledger_path=args.ledger, repo_root=args.root)
|
|
463
|
+
|
|
464
|
+
if args.seed:
|
|
465
|
+
issued = seed_baseline_certifications(ledger)
|
|
466
|
+
if args.json:
|
|
467
|
+
print(json.dumps([c.to_dict() for c in issued], indent=2))
|
|
468
|
+
else:
|
|
469
|
+
print(f"Seeded {len(issued)} baseline certificates into {ledger.ledger_path}")
|
|
470
|
+
return 0
|
|
471
|
+
|
|
472
|
+
if args.recertify:
|
|
473
|
+
cert = recertify_component(ledger, args.recertify)
|
|
474
|
+
if args.json:
|
|
475
|
+
print(json.dumps(cert.to_dict(), indent=2))
|
|
476
|
+
else:
|
|
477
|
+
print(f"Recertified {cert.component_ref} -> {cert.certificate_id} ({cert.state})")
|
|
478
|
+
return 0
|
|
479
|
+
|
|
480
|
+
if args.verify:
|
|
481
|
+
res = ledger.verify_ledger_integrity()
|
|
482
|
+
if args.json:
|
|
483
|
+
print(json.dumps(res, indent=2))
|
|
484
|
+
else:
|
|
485
|
+
status = "PASS" if res["valid"] else "FAIL"
|
|
486
|
+
print(f"Ledger Integrity: {status} ({res['count']} records verified)")
|
|
487
|
+
for err in res["errors"]:
|
|
488
|
+
print(f" ERROR: {err}")
|
|
489
|
+
return 0 if res["valid"] else 1
|
|
490
|
+
|
|
491
|
+
active = ledger.get_active_certificates()
|
|
492
|
+
if args.json:
|
|
493
|
+
print(json.dumps({k: v.to_dict() for k, v in active.items()}, indent=2))
|
|
494
|
+
else:
|
|
495
|
+
print(f"Active Certificates ({len(active)} components):")
|
|
496
|
+
for k, cert in active.items():
|
|
497
|
+
print(f" [{cert.state}] {k} -> {cert.certificate_id} ({cert.certified_commit[:8] if cert.certified_commit else 'n/a'})")
|
|
498
|
+
|
|
499
|
+
return 0
|
|
500
|
+
|
|
501
|
+
|
|
502
|
+
if __name__ == "__main__":
|
|
503
|
+
import sys
|
|
504
|
+
sys.exit(main())
|
|
505
|
+
|
|
506
|
+
|