diff --git a/epiphany-core/src/bin/epiphany-work.rs b/epiphany-core/src/bin/epiphany-work.rs index 4a2b5c29..7816dc54 100644 --- a/epiphany-core/src/bin/epiphany-work.rs +++ b/epiphany-core/src/bin/epiphany-work.rs @@ -87,7 +87,6 @@ use epiphany_core::write_epiphany_cultmesh_repo_work_readiness; use epiphany_core::write_epiphany_cultmesh_weksa_lowering_receipt; use epiphany_state_model::EpiphanyMemoryContextQuery; use epiphany_state_model::EpiphanyMemoryProfile; -use serde::Deserialize; use serde_json::Value; use serde_json::json; use sha2::Digest; @@ -98,6 +97,10 @@ use std::path::Path; use std::path::PathBuf; use std::process::Command; +#[path = "epiphany_work/closure_contracts.rs"] +mod closure_contracts; +use closure_contracts::*; + fn main() -> Result<()> { let mut args = env::args().skip(1); let Some(command) = args.next() else { @@ -12102,556 +12105,6 @@ fn run_readiness(args: ReadinessArgs) -> Result { })) } -#[derive(Debug, Deserialize)] -struct RepoDeploymentConfig { - schema_version: String, - safe_action_family: String, - summary: String, - private_state_exposed: bool, - deployment: RepoDeploymentSettings, - cultmesh: RepoDeploymentCultMesh, - required_receipts: RepoDeploymentRequiredReceipts, - authority: RepoDeploymentAuthority, -} - -impl RepoDeploymentConfig { - fn has_canonical_identity(&self) -> bool { - self.schema_version == "epiphany.repo_deployment_config.v0" - && self.safe_action_family == "repo.deployment_config" - } - - fn has_idunn_trigger_contract(&self) -> bool { - let deployment = &self.deployment; - !deployment.enabled - && deployment.owner == "Idunn" - && deployment.trigger == "git-push-observed-by-idunn" - && deployment.watched_ref == "refs/heads/main" - && deployment.deployment_script_ref == "deploy/idunn-deploy.ps1" - && deployment.deployment_script_hash_required - && deployment.deployment_script_review_required - && deployment.host_access_policy_ref_required - && !deployment.secret_values_embedded - && deployment.rollback_plan_ref_required - && deployment.aftercare_checks_required - && deployment.idunn_receipt_required - && deployment.aftercare_audit_required - } - - fn has_cultmesh_contract(&self) -> bool { - let cultmesh = &self.cultmesh; - cultmesh.local_verse == "gamecult-local" - && cultmesh.capability_family == "gamecult.idunn.deployment" - && cultmesh.intent_contract == "gamecult.idunn.deployment_intent.v0" - && cultmesh.receipt_contract == "gamecult.idunn.deployment_receipt.v0" - && cultmesh.aftercare_contract == "gamecult.idunn.deployment_aftercare_audit.v0" - && cultmesh.daemon_owns_execution - } - - fn has_required_receipt_contract(&self) -> bool { - let receipts = &self.required_receipts; - receipts.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" - && receipts.soul_review == "epiphany.repo_work_closure_review.v0" - && receipts.maintainer_review == "gamecult.maintainer.review_receipt.v0" - && receipts.secret_policy == "epiphany.repo_secret_policy_request.v0" - && receipts.idunn_deployment == "gamecult.idunn.deployment_receipt.v0" - && receipts.aftercare_audit == "gamecult.idunn.deployment_aftercare_audit.v0" - } - - fn has_authority_seals(&self) -> bool { - let authority = &self.authority; - authority.configuration_only - && !authority.direct_deployment_authority - && !authority.direct_ssh_authority - && !authority.direct_git_push_authority - && !authority.direct_service_lifecycle_authority - && !authority.direct_hands_authority - && !authority.publication_authorized - && !authority.merge_authorized - && !authority.cross_body_mutation_authorized - && !authority.private_verse_rummaging - && authority.idunn_deployment_authority_required - } -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentSettings { - enabled: bool, - owner: String, - trigger: String, - watched_ref: String, - deployment_script_ref: String, - deployment_script_hash_required: bool, - deployment_script_review_required: bool, - host_access_policy_ref_required: bool, - secret_values_embedded: bool, - rollback_plan_ref_required: bool, - aftercare_checks_required: bool, - idunn_receipt_required: bool, - aftercare_audit_required: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentCultMesh { - local_verse: String, - capability_family: String, - intent_contract: String, - receipt_contract: String, - aftercare_contract: String, - daemon_owns_execution: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequiredReceipts { - mind_adoption: String, - soul_review: String, - maintainer_review: String, - secret_policy: String, - idunn_deployment: String, - aftercare_audit: String, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentAuthority { - configuration_only: bool, - direct_deployment_authority: bool, - direct_ssh_authority: bool, - direct_git_push_authority: bool, - direct_service_lifecycle_authority: bool, - direct_hands_authority: bool, - publication_authorized: bool, - merge_authorized: bool, - cross_body_mutation_authorized: bool, - private_verse_rummaging: bool, - idunn_deployment_authority_required: bool, -} - -fn parse_repo_deployment_config(text: &str) -> Result { - toml::from_str(text).context("deployment config is not valid typed TOML") -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyRequest { - schema_version: String, - safe_action_family: String, - summary: String, - private_state_exposed: bool, - request: RepoSecretPolicyRequestBody, - antecedents: RepoSecretPolicyAntecedents, - required_receipts: RepoSecretPolicyReceipts, - security_packet: RepoSecretPolicyPacket, - authority: RepoSecretPolicyAuthority, -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyRequestBody { - status: String, - requested_owner: String, - requested_effect: String, - requires_secret_inventory_without_values: bool, - requires_write_permission_scope: bool, - requires_public_private_export_boundary: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyAntecedents { - source_grounding_required: bool, - soul_review_required: bool, - mind_adoption_required: bool, - maintainer_review_required: bool, - bifrost_publication_review_required: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyReceipts { - source_grounding: String, - soul_review: String, - mind_adoption: String, - maintainer_review: String, - bifrost_publication_review: String, -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyPacket { - requires_secret_locations_without_values: bool, - requires_credential_owner: bool, - requires_write_scope_matrix: bool, - requires_public_export_redaction_rules: bool, - requires_deployment_authority_owner: bool, - requires_incident_rollback_plan: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoSecretPolicyAuthority { - direct_secret_access_authority: bool, - secret_value_materialization: bool, - write_permission_authority: bool, - deployment_authority: bool, - publication_authorized: bool, - merge_authorized: bool, - service_lifecycle_authority: bool, - cross_body_mutation_authorized: bool, - private_verse_rummaging: bool, - maintainer_or_soul_security_authority_required: bool, -} - -impl RepoSecretPolicyRequest { - fn has_canonical_identity(&self) -> bool { - self.schema_version == "epiphany.repo_secret_policy_request.v0" - && self.safe_action_family == "repo.secret_policy_request" - } - - fn awaits_security_review(&self) -> bool { - let request = &self.request; - request.status == "awaiting-security-review" - && request.requested_owner == "Maintainer/Soul/Bifrost" - && request.requested_effect == "review-repo-secret-and-write-permission-policy" - && request.requires_secret_inventory_without_values - && request.requires_write_permission_scope - && request.requires_public_private_export_boundary - } - - fn has_review_antecedents(&self) -> bool { - let antecedents = &self.antecedents; - antecedents.source_grounding_required - && antecedents.soul_review_required - && antecedents.mind_adoption_required - && antecedents.maintainer_review_required - && antecedents.bifrost_publication_review_required - } - - fn has_receipt_contract(&self) -> bool { - let receipts = &self.required_receipts; - receipts.source_grounding == "epiphany.eyes.evidence_packet" - && receipts.soul_review == "epiphany.repo_work_closure_review.v0" - && receipts.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" - && receipts.maintainer_review == "gamecult.maintainer.review_receipt.v0" - && receipts.bifrost_publication_review - == "gamecult.bifrost.publication_review_receipt.v0" - } - - fn has_security_packet_contract(&self) -> bool { - let packet = &self.security_packet; - packet.requires_secret_locations_without_values - && packet.requires_credential_owner - && packet.requires_write_scope_matrix - && packet.requires_public_export_redaction_rules - && packet.requires_deployment_authority_owner - && packet.requires_incident_rollback_plan - } - - fn has_authority_seals(&self) -> bool { - let authority = &self.authority; - !authority.direct_secret_access_authority - && !authority.secret_value_materialization - && !authority.write_permission_authority - && !authority.deployment_authority - && !authority.publication_authorized - && !authority.merge_authorized - && !authority.service_lifecycle_authority - && !authority.cross_body_mutation_authorized - && !authority.private_verse_rummaging - && authority.maintainer_or_soul_security_authority_required - } -} - -fn parse_repo_secret_policy_request(text: &str) -> Result { - toml::from_str(text).context("secret policy request is not valid typed TOML") -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyRequest { - schema_version: String, - safe_action_family: String, - summary: String, - private_state_exposed: bool, - request: RepoDependencyPolicyRequestBody, - antecedents: RepoDependencyPolicyAntecedents, - required_receipts: RepoDependencyPolicyReceipts, - dependency_packet: RepoDependencyPolicyPacket, - authority: RepoDependencyPolicyAuthority, -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyRequestBody { - status: String, - requested_owner: String, - requested_effect: String, - requires_manifest_inventory: bool, - requires_lockfile_policy: bool, - requires_package_manager_command_review: bool, - requires_network_fetch_policy: bool, - requires_vulnerability_review: bool, - requires_license_review: bool, - requires_rollback_plan: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyAntecedents { - source_grounding_required: bool, - eyes_evidence_required: bool, - soul_review_required: bool, - mind_adoption_required: bool, - maintainer_review_required: bool, - bifrost_publication_review_required: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyReceipts { - source_grounding: String, - soul_review: String, - mind_adoption: String, - maintainer_review: String, - bifrost_publication_review: String, - dependency_audit: String, -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyPacket { - requires_manifest_paths: bool, - requires_lockfile_paths: bool, - requires_package_manager_commands: bool, - requires_vulnerability_sources: bool, - requires_license_constraints: bool, - requires_vendored_code_policy: bool, - requires_update_cadence: bool, - requires_private_state_redaction_check: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDependencyPolicyAuthority { - direct_dependency_update_authority: bool, - direct_package_install_authority: bool, - direct_lockfile_mutation_authority: bool, - direct_network_fetch_authority: bool, - direct_ci_mutation_authority: bool, - direct_hands_authority: bool, - publication_authorized: bool, - merge_authorized: bool, - deployment_authority: bool, - service_lifecycle_authority: bool, - cross_body_mutation_authorized: bool, - private_verse_rummaging: bool, - maintainer_or_soul_dependency_authority_required: bool, -} - -impl RepoDependencyPolicyRequest { - fn has_canonical_identity(&self) -> bool { - self.schema_version == "epiphany.repo_dependency_policy_request.v0" - && self.safe_action_family == "repo.dependency_policy_request" - } - - fn awaits_review(&self) -> bool { - let request = &self.request; - request.status == "awaiting-dependency-policy-review" - && request.requested_owner == "Maintainer/Soul/Bifrost" - && request.requested_effect == "review-repo-dependency-and-supply-chain-policy" - && request.requires_manifest_inventory - && request.requires_lockfile_policy - && request.requires_package_manager_command_review - && request.requires_network_fetch_policy - && request.requires_vulnerability_review - && request.requires_license_review - && request.requires_rollback_plan - } - - fn has_antecedents(&self) -> bool { - let value = &self.antecedents; - value.source_grounding_required - && value.eyes_evidence_required - && value.soul_review_required - && value.mind_adoption_required - && value.maintainer_review_required - && value.bifrost_publication_review_required - } - - fn has_receipt_contract(&self) -> bool { - let value = &self.required_receipts; - value.source_grounding == "epiphany.eyes.evidence_packet" - && value.soul_review == "epiphany.repo_work_closure_review.v0" - && value.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" - && value.maintainer_review == "gamecult.maintainer.review_receipt.v0" - && value.bifrost_publication_review == "gamecult.bifrost.publication_review_receipt.v0" - && value.dependency_audit == "gamecult.supply_chain.dependency_audit_receipt.v0" - } - - fn has_packet_contract(&self) -> bool { - let value = &self.dependency_packet; - value.requires_manifest_paths - && value.requires_lockfile_paths - && value.requires_package_manager_commands - && value.requires_vulnerability_sources - && value.requires_license_constraints - && value.requires_vendored_code_policy - && value.requires_update_cadence - && value.requires_private_state_redaction_check - } - - fn has_authority_seals(&self) -> bool { - let value = &self.authority; - !value.direct_dependency_update_authority - && !value.direct_package_install_authority - && !value.direct_lockfile_mutation_authority - && !value.direct_network_fetch_authority - && !value.direct_ci_mutation_authority - && !value.direct_hands_authority - && !value.publication_authorized - && !value.merge_authorized - && !value.deployment_authority - && !value.service_lifecycle_authority - && !value.cross_body_mutation_authorized - && !value.private_verse_rummaging - && value.maintainer_or_soul_dependency_authority_required - } -} - -fn parse_repo_dependency_policy_request(text: &str) -> Result { - toml::from_str(text).context("dependency policy request is not valid typed TOML") -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequest { - schema_version: String, - safe_action_family: String, - summary: String, - private_state_exposed: bool, - request: RepoDeploymentRequestBody, - antecedents: RepoDeploymentRequestAntecedents, - required_receipts: RepoDeploymentRequestReceipts, - deployment_packet: RepoDeploymentRequestPacket, - authority: RepoDeploymentRequestAuthority, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequestBody { - status: String, - requested_owner: String, - requested_effect: String, - deployment_trigger: String, - deployment_owner: String, - requires_explicit_deployment_policy: bool, - requires_idunn_receipt: bool, - requires_aftercare_audit: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequestAntecedents { - source_grounding_required: bool, - mind_adoption_required: bool, - soul_review_required: bool, - maintainer_review_required: bool, - secret_policy_review_required: bool, - bifrost_publication_review_required: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequestReceipts { - source_grounding: String, - mind_adoption: String, - soul_review: String, - maintainer_review: String, - secret_policy: String, - bifrost_publication_review: String, - idunn_deployment: String, - aftercare_audit: String, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequestPacket { - requires_target_environment: bool, - requires_git_ref_or_branch: bool, - requires_deployment_script_ref: bool, - requires_script_hash_or_review_ref: bool, - requires_host_access_policy_ref: bool, - requires_secret_policy_ref: bool, - requires_rollback_plan: bool, - requires_aftercare_checks: bool, -} - -#[derive(Debug, Deserialize)] -struct RepoDeploymentRequestAuthority { - direct_deployment_authority: bool, - direct_ssh_authority: bool, - direct_git_push_authority: bool, - direct_service_lifecycle_authority: bool, - direct_hands_authority: bool, - publication_authorized: bool, - merge_authorized: bool, - cross_body_mutation_authorized: bool, - private_verse_rummaging: bool, - idunn_deployment_authority_required: bool, -} - -impl RepoDeploymentRequest { - fn has_canonical_identity(&self) -> bool { - self.schema_version == "epiphany.repo_deployment_request.v0" - && self.safe_action_family == "repo.deployment_request" - } - - fn awaits_idunn_review(&self) -> bool { - let value = &self.request; - value.status == "awaiting-idunn-review" - && value.requested_owner == "Idunn/Maintainer" - && value.requested_effect == "review-repo-deployment-trigger-and-script" - && value.deployment_trigger == "git-push-observed-by-idunn" - && value.deployment_owner == "Idunn" - && value.requires_explicit_deployment_policy - && value.requires_idunn_receipt - && value.requires_aftercare_audit - } - - fn has_antecedents(&self) -> bool { - let value = &self.antecedents; - value.source_grounding_required - && value.mind_adoption_required - && value.soul_review_required - && value.maintainer_review_required - && value.secret_policy_review_required - && value.bifrost_publication_review_required - } - - fn has_receipt_contract(&self) -> bool { - let value = &self.required_receipts; - value.source_grounding == "epiphany.eyes.evidence_packet" - && value.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" - && value.soul_review == "epiphany.repo_work_closure_review.v0" - && value.maintainer_review == "gamecult.maintainer.review_receipt.v0" - && value.secret_policy == "epiphany.repo_secret_policy_request.v0" - && value.bifrost_publication_review == "gamecult.bifrost.publication_review_receipt.v0" - && value.idunn_deployment == "gamecult.idunn.deployment_receipt.v0" - && value.aftercare_audit == "gamecult.idunn.deployment_aftercare_audit.v0" - } - - fn has_packet_contract(&self) -> bool { - let value = &self.deployment_packet; - value.requires_target_environment - && value.requires_git_ref_or_branch - && value.requires_deployment_script_ref - && value.requires_script_hash_or_review_ref - && value.requires_host_access_policy_ref - && value.requires_secret_policy_ref - && value.requires_rollback_plan - && value.requires_aftercare_checks - } - - fn has_authority_seals(&self) -> bool { - let value = &self.authority; - !value.direct_deployment_authority - && !value.direct_ssh_authority - && !value.direct_git_push_authority - && !value.direct_service_lifecycle_authority - && !value.direct_hands_authority - && !value.publication_authorized - && !value.merge_authorized - && !value.cross_body_mutation_authorized - && !value.private_verse_rummaging - && value.idunn_deployment_authority_required - } -} - -fn parse_repo_deployment_request(text: &str) -> Result { - toml::from_str(text).context("deployment request is not valid typed TOML") -} - fn run_deployment_config_audit(args: DeploymentConfigAuditArgs) -> Result { let workspace = args .workspace diff --git a/epiphany-core/src/bin/epiphany_work/closure_contracts.rs b/epiphany-core/src/bin/epiphany_work/closure_contracts.rs new file mode 100644 index 00000000..0f1ff7bd --- /dev/null +++ b/epiphany-core/src/bin/epiphany_work/closure_contracts.rs @@ -0,0 +1,554 @@ +use anyhow::{Context, Result}; +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentConfig { + pub(super) schema_version: String, + pub(super) safe_action_family: String, + pub(super) summary: String, + pub(super) private_state_exposed: bool, + pub(super) deployment: RepoDeploymentSettings, + pub(super) cultmesh: RepoDeploymentCultMesh, + pub(super) required_receipts: RepoDeploymentRequiredReceipts, + pub(super) authority: RepoDeploymentAuthority, +} + +impl RepoDeploymentConfig { + pub(super) fn has_canonical_identity(&self) -> bool { + self.schema_version == "epiphany.repo_deployment_config.v0" + && self.safe_action_family == "repo.deployment_config" + } + + pub(super) fn has_idunn_trigger_contract(&self) -> bool { + let deployment = &self.deployment; + !deployment.enabled + && deployment.owner == "Idunn" + && deployment.trigger == "git-push-observed-by-idunn" + && deployment.watched_ref == "refs/heads/main" + && deployment.deployment_script_ref == "deploy/idunn-deploy.ps1" + && deployment.deployment_script_hash_required + && deployment.deployment_script_review_required + && deployment.host_access_policy_ref_required + && !deployment.secret_values_embedded + && deployment.rollback_plan_ref_required + && deployment.aftercare_checks_required + && deployment.idunn_receipt_required + && deployment.aftercare_audit_required + } + + pub(super) fn has_cultmesh_contract(&self) -> bool { + let cultmesh = &self.cultmesh; + cultmesh.local_verse == "gamecult-local" + && cultmesh.capability_family == "gamecult.idunn.deployment" + && cultmesh.intent_contract == "gamecult.idunn.deployment_intent.v0" + && cultmesh.receipt_contract == "gamecult.idunn.deployment_receipt.v0" + && cultmesh.aftercare_contract == "gamecult.idunn.deployment_aftercare_audit.v0" + && cultmesh.daemon_owns_execution + } + + pub(super) fn has_required_receipt_contract(&self) -> bool { + let receipts = &self.required_receipts; + receipts.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" + && receipts.soul_review == "epiphany.repo_work_closure_review.v0" + && receipts.maintainer_review == "gamecult.maintainer.review_receipt.v0" + && receipts.secret_policy == "epiphany.repo_secret_policy_request.v0" + && receipts.idunn_deployment == "gamecult.idunn.deployment_receipt.v0" + && receipts.aftercare_audit == "gamecult.idunn.deployment_aftercare_audit.v0" + } + + pub(super) fn has_authority_seals(&self) -> bool { + let authority = &self.authority; + authority.configuration_only + && !authority.direct_deployment_authority + && !authority.direct_ssh_authority + && !authority.direct_git_push_authority + && !authority.direct_service_lifecycle_authority + && !authority.direct_hands_authority + && !authority.publication_authorized + && !authority.merge_authorized + && !authority.cross_body_mutation_authorized + && !authority.private_verse_rummaging + && authority.idunn_deployment_authority_required + } +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentSettings { + pub(super) enabled: bool, + pub(super) owner: String, + pub(super) trigger: String, + pub(super) watched_ref: String, + pub(super) deployment_script_ref: String, + pub(super) deployment_script_hash_required: bool, + pub(super) deployment_script_review_required: bool, + pub(super) host_access_policy_ref_required: bool, + pub(super) secret_values_embedded: bool, + pub(super) rollback_plan_ref_required: bool, + pub(super) aftercare_checks_required: bool, + pub(super) idunn_receipt_required: bool, + pub(super) aftercare_audit_required: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentCultMesh { + pub(super) local_verse: String, + pub(super) capability_family: String, + pub(super) intent_contract: String, + pub(super) receipt_contract: String, + pub(super) aftercare_contract: String, + pub(super) daemon_owns_execution: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequiredReceipts { + pub(super) mind_adoption: String, + pub(super) soul_review: String, + pub(super) maintainer_review: String, + pub(super) secret_policy: String, + pub(super) idunn_deployment: String, + pub(super) aftercare_audit: String, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentAuthority { + pub(super) configuration_only: bool, + pub(super) direct_deployment_authority: bool, + pub(super) direct_ssh_authority: bool, + pub(super) direct_git_push_authority: bool, + pub(super) direct_service_lifecycle_authority: bool, + pub(super) direct_hands_authority: bool, + pub(super) publication_authorized: bool, + pub(super) merge_authorized: bool, + pub(super) cross_body_mutation_authorized: bool, + pub(super) private_verse_rummaging: bool, + pub(super) idunn_deployment_authority_required: bool, +} + +pub(super) fn parse_repo_deployment_config(text: &str) -> Result { + toml::from_str(text).context("deployment config is not valid typed TOML") +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyRequest { + pub(super) schema_version: String, + pub(super) safe_action_family: String, + pub(super) summary: String, + pub(super) private_state_exposed: bool, + pub(super) request: RepoSecretPolicyRequestBody, + pub(super) antecedents: RepoSecretPolicyAntecedents, + pub(super) required_receipts: RepoSecretPolicyReceipts, + pub(super) security_packet: RepoSecretPolicyPacket, + pub(super) authority: RepoSecretPolicyAuthority, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyRequestBody { + pub(super) status: String, + pub(super) requested_owner: String, + pub(super) requested_effect: String, + pub(super) requires_secret_inventory_without_values: bool, + pub(super) requires_write_permission_scope: bool, + pub(super) requires_public_private_export_boundary: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyAntecedents { + pub(super) source_grounding_required: bool, + pub(super) soul_review_required: bool, + pub(super) mind_adoption_required: bool, + pub(super) maintainer_review_required: bool, + pub(super) bifrost_publication_review_required: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyReceipts { + pub(super) source_grounding: String, + pub(super) soul_review: String, + pub(super) mind_adoption: String, + pub(super) maintainer_review: String, + pub(super) bifrost_publication_review: String, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyPacket { + pub(super) requires_secret_locations_without_values: bool, + pub(super) requires_credential_owner: bool, + pub(super) requires_write_scope_matrix: bool, + pub(super) requires_public_export_redaction_rules: bool, + pub(super) requires_deployment_authority_owner: bool, + pub(super) requires_incident_rollback_plan: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoSecretPolicyAuthority { + pub(super) direct_secret_access_authority: bool, + pub(super) secret_value_materialization: bool, + pub(super) write_permission_authority: bool, + pub(super) deployment_authority: bool, + pub(super) publication_authorized: bool, + pub(super) merge_authorized: bool, + pub(super) service_lifecycle_authority: bool, + pub(super) cross_body_mutation_authorized: bool, + pub(super) private_verse_rummaging: bool, + pub(super) maintainer_or_soul_security_authority_required: bool, +} + +impl RepoSecretPolicyRequest { + pub(super) fn has_canonical_identity(&self) -> bool { + self.schema_version == "epiphany.repo_secret_policy_request.v0" + && self.safe_action_family == "repo.secret_policy_request" + } + + pub(super) fn awaits_security_review(&self) -> bool { + let request = &self.request; + request.status == "awaiting-security-review" + && request.requested_owner == "Maintainer/Soul/Bifrost" + && request.requested_effect == "review-repo-secret-and-write-permission-policy" + && request.requires_secret_inventory_without_values + && request.requires_write_permission_scope + && request.requires_public_private_export_boundary + } + + pub(super) fn has_review_antecedents(&self) -> bool { + let antecedents = &self.antecedents; + antecedents.source_grounding_required + && antecedents.soul_review_required + && antecedents.mind_adoption_required + && antecedents.maintainer_review_required + && antecedents.bifrost_publication_review_required + } + + pub(super) fn has_receipt_contract(&self) -> bool { + let receipts = &self.required_receipts; + receipts.source_grounding == "epiphany.eyes.evidence_packet" + && receipts.soul_review == "epiphany.repo_work_closure_review.v0" + && receipts.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" + && receipts.maintainer_review == "gamecult.maintainer.review_receipt.v0" + && receipts.bifrost_publication_review + == "gamecult.bifrost.publication_review_receipt.v0" + } + + pub(super) fn has_security_packet_contract(&self) -> bool { + let packet = &self.security_packet; + packet.requires_secret_locations_without_values + && packet.requires_credential_owner + && packet.requires_write_scope_matrix + && packet.requires_public_export_redaction_rules + && packet.requires_deployment_authority_owner + && packet.requires_incident_rollback_plan + } + + pub(super) fn has_authority_seals(&self) -> bool { + let authority = &self.authority; + !authority.direct_secret_access_authority + && !authority.secret_value_materialization + && !authority.write_permission_authority + && !authority.deployment_authority + && !authority.publication_authorized + && !authority.merge_authorized + && !authority.service_lifecycle_authority + && !authority.cross_body_mutation_authorized + && !authority.private_verse_rummaging + && authority.maintainer_or_soul_security_authority_required + } +} + +pub(super) fn parse_repo_secret_policy_request(text: &str) -> Result { + toml::from_str(text).context("secret policy request is not valid typed TOML") +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyRequest { + pub(super) schema_version: String, + pub(super) safe_action_family: String, + pub(super) summary: String, + pub(super) private_state_exposed: bool, + pub(super) request: RepoDependencyPolicyRequestBody, + pub(super) antecedents: RepoDependencyPolicyAntecedents, + pub(super) required_receipts: RepoDependencyPolicyReceipts, + pub(super) dependency_packet: RepoDependencyPolicyPacket, + pub(super) authority: RepoDependencyPolicyAuthority, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyRequestBody { + pub(super) status: String, + pub(super) requested_owner: String, + pub(super) requested_effect: String, + pub(super) requires_manifest_inventory: bool, + pub(super) requires_lockfile_policy: bool, + pub(super) requires_package_manager_command_review: bool, + pub(super) requires_network_fetch_policy: bool, + pub(super) requires_vulnerability_review: bool, + pub(super) requires_license_review: bool, + pub(super) requires_rollback_plan: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyAntecedents { + pub(super) source_grounding_required: bool, + pub(super) eyes_evidence_required: bool, + pub(super) soul_review_required: bool, + pub(super) mind_adoption_required: bool, + pub(super) maintainer_review_required: bool, + pub(super) bifrost_publication_review_required: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyReceipts { + pub(super) source_grounding: String, + pub(super) soul_review: String, + pub(super) mind_adoption: String, + pub(super) maintainer_review: String, + pub(super) bifrost_publication_review: String, + pub(super) dependency_audit: String, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyPacket { + pub(super) requires_manifest_paths: bool, + pub(super) requires_lockfile_paths: bool, + pub(super) requires_package_manager_commands: bool, + pub(super) requires_vulnerability_sources: bool, + pub(super) requires_license_constraints: bool, + pub(super) requires_vendored_code_policy: bool, + pub(super) requires_update_cadence: bool, + pub(super) requires_private_state_redaction_check: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDependencyPolicyAuthority { + pub(super) direct_dependency_update_authority: bool, + pub(super) direct_package_install_authority: bool, + pub(super) direct_lockfile_mutation_authority: bool, + pub(super) direct_network_fetch_authority: bool, + pub(super) direct_ci_mutation_authority: bool, + pub(super) direct_hands_authority: bool, + pub(super) publication_authorized: bool, + pub(super) merge_authorized: bool, + pub(super) deployment_authority: bool, + pub(super) service_lifecycle_authority: bool, + pub(super) cross_body_mutation_authorized: bool, + pub(super) private_verse_rummaging: bool, + pub(super) maintainer_or_soul_dependency_authority_required: bool, +} + +impl RepoDependencyPolicyRequest { + pub(super) fn has_canonical_identity(&self) -> bool { + self.schema_version == "epiphany.repo_dependency_policy_request.v0" + && self.safe_action_family == "repo.dependency_policy_request" + } + + pub(super) fn awaits_review(&self) -> bool { + let request = &self.request; + request.status == "awaiting-dependency-policy-review" + && request.requested_owner == "Maintainer/Soul/Bifrost" + && request.requested_effect == "review-repo-dependency-and-supply-chain-policy" + && request.requires_manifest_inventory + && request.requires_lockfile_policy + && request.requires_package_manager_command_review + && request.requires_network_fetch_policy + && request.requires_vulnerability_review + && request.requires_license_review + && request.requires_rollback_plan + } + + pub(super) fn has_antecedents(&self) -> bool { + let value = &self.antecedents; + value.source_grounding_required + && value.eyes_evidence_required + && value.soul_review_required + && value.mind_adoption_required + && value.maintainer_review_required + && value.bifrost_publication_review_required + } + + pub(super) fn has_receipt_contract(&self) -> bool { + let value = &self.required_receipts; + value.source_grounding == "epiphany.eyes.evidence_packet" + && value.soul_review == "epiphany.repo_work_closure_review.v0" + && value.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" + && value.maintainer_review == "gamecult.maintainer.review_receipt.v0" + && value.bifrost_publication_review == "gamecult.bifrost.publication_review_receipt.v0" + && value.dependency_audit == "gamecult.supply_chain.dependency_audit_receipt.v0" + } + + pub(super) fn has_packet_contract(&self) -> bool { + let value = &self.dependency_packet; + value.requires_manifest_paths + && value.requires_lockfile_paths + && value.requires_package_manager_commands + && value.requires_vulnerability_sources + && value.requires_license_constraints + && value.requires_vendored_code_policy + && value.requires_update_cadence + && value.requires_private_state_redaction_check + } + + pub(super) fn has_authority_seals(&self) -> bool { + let value = &self.authority; + !value.direct_dependency_update_authority + && !value.direct_package_install_authority + && !value.direct_lockfile_mutation_authority + && !value.direct_network_fetch_authority + && !value.direct_ci_mutation_authority + && !value.direct_hands_authority + && !value.publication_authorized + && !value.merge_authorized + && !value.deployment_authority + && !value.service_lifecycle_authority + && !value.cross_body_mutation_authorized + && !value.private_verse_rummaging + && value.maintainer_or_soul_dependency_authority_required + } +} + +pub(super) fn parse_repo_dependency_policy_request( + text: &str, +) -> Result { + toml::from_str(text).context("dependency policy request is not valid typed TOML") +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequest { + pub(super) schema_version: String, + pub(super) safe_action_family: String, + pub(super) summary: String, + pub(super) private_state_exposed: bool, + pub(super) request: RepoDeploymentRequestBody, + pub(super) antecedents: RepoDeploymentRequestAntecedents, + pub(super) required_receipts: RepoDeploymentRequestReceipts, + pub(super) deployment_packet: RepoDeploymentRequestPacket, + pub(super) authority: RepoDeploymentRequestAuthority, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequestBody { + pub(super) status: String, + pub(super) requested_owner: String, + pub(super) requested_effect: String, + pub(super) deployment_trigger: String, + pub(super) deployment_owner: String, + pub(super) requires_explicit_deployment_policy: bool, + pub(super) requires_idunn_receipt: bool, + pub(super) requires_aftercare_audit: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequestAntecedents { + pub(super) source_grounding_required: bool, + pub(super) mind_adoption_required: bool, + pub(super) soul_review_required: bool, + pub(super) maintainer_review_required: bool, + pub(super) secret_policy_review_required: bool, + pub(super) bifrost_publication_review_required: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequestReceipts { + pub(super) source_grounding: String, + pub(super) mind_adoption: String, + pub(super) soul_review: String, + pub(super) maintainer_review: String, + pub(super) secret_policy: String, + pub(super) bifrost_publication_review: String, + pub(super) idunn_deployment: String, + pub(super) aftercare_audit: String, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequestPacket { + pub(super) requires_target_environment: bool, + pub(super) requires_git_ref_or_branch: bool, + pub(super) requires_deployment_script_ref: bool, + pub(super) requires_script_hash_or_review_ref: bool, + pub(super) requires_host_access_policy_ref: bool, + pub(super) requires_secret_policy_ref: bool, + pub(super) requires_rollback_plan: bool, + pub(super) requires_aftercare_checks: bool, +} + +#[derive(Debug, Deserialize)] +pub(super) struct RepoDeploymentRequestAuthority { + pub(super) direct_deployment_authority: bool, + pub(super) direct_ssh_authority: bool, + pub(super) direct_git_push_authority: bool, + pub(super) direct_service_lifecycle_authority: bool, + pub(super) direct_hands_authority: bool, + pub(super) publication_authorized: bool, + pub(super) merge_authorized: bool, + pub(super) cross_body_mutation_authorized: bool, + pub(super) private_verse_rummaging: bool, + pub(super) idunn_deployment_authority_required: bool, +} + +impl RepoDeploymentRequest { + pub(super) fn has_canonical_identity(&self) -> bool { + self.schema_version == "epiphany.repo_deployment_request.v0" + && self.safe_action_family == "repo.deployment_request" + } + + pub(super) fn awaits_idunn_review(&self) -> bool { + let value = &self.request; + value.status == "awaiting-idunn-review" + && value.requested_owner == "Idunn/Maintainer" + && value.requested_effect == "review-repo-deployment-trigger-and-script" + && value.deployment_trigger == "git-push-observed-by-idunn" + && value.deployment_owner == "Idunn" + && value.requires_explicit_deployment_policy + && value.requires_idunn_receipt + && value.requires_aftercare_audit + } + + pub(super) fn has_antecedents(&self) -> bool { + let value = &self.antecedents; + value.source_grounding_required + && value.mind_adoption_required + && value.soul_review_required + && value.maintainer_review_required + && value.secret_policy_review_required + && value.bifrost_publication_review_required + } + + pub(super) fn has_receipt_contract(&self) -> bool { + let value = &self.required_receipts; + value.source_grounding == "epiphany.eyes.evidence_packet" + && value.mind_adoption == "epiphany.repo_work_mind_adoption_decision.v0" + && value.soul_review == "epiphany.repo_work_closure_review.v0" + && value.maintainer_review == "gamecult.maintainer.review_receipt.v0" + && value.secret_policy == "epiphany.repo_secret_policy_request.v0" + && value.bifrost_publication_review == "gamecult.bifrost.publication_review_receipt.v0" + && value.idunn_deployment == "gamecult.idunn.deployment_receipt.v0" + && value.aftercare_audit == "gamecult.idunn.deployment_aftercare_audit.v0" + } + + pub(super) fn has_packet_contract(&self) -> bool { + let value = &self.deployment_packet; + value.requires_target_environment + && value.requires_git_ref_or_branch + && value.requires_deployment_script_ref + && value.requires_script_hash_or_review_ref + && value.requires_host_access_policy_ref + && value.requires_secret_policy_ref + && value.requires_rollback_plan + && value.requires_aftercare_checks + } + + pub(super) fn has_authority_seals(&self) -> bool { + let value = &self.authority; + !value.direct_deployment_authority + && !value.direct_ssh_authority + && !value.direct_git_push_authority + && !value.direct_service_lifecycle_authority + && !value.direct_hands_authority + && !value.publication_authorized + && !value.merge_authorized + && !value.cross_body_mutation_authorized + && !value.private_verse_rummaging + && value.idunn_deployment_authority_required + } +} + +pub(super) fn parse_repo_deployment_request(text: &str) -> Result { + toml::from_str(text).context("deployment request is not valid typed TOML") +} diff --git a/notes/conceptual-substitution-audit-2026-07-12.md b/notes/conceptual-substitution-audit-2026-07-12.md index 5cd49418..0fd9b767 100644 --- a/notes/conceptual-substitution-audit-2026-07-12.md +++ b/notes/conceptual-substitution-audit-2026-07-12.md @@ -778,14 +778,16 @@ target at actuation time. The target must be a strict descendant of the quarantine; junctions or other resolution escapes are refused. An outside sentinel survives a counterfeit store path. -## Structural pressure: closure contracts need extraction +## Closure-contract ownership extracted from command orchestration The typed deployment, deployment-request, secret-policy, and dependency-policy -models now form a contiguous contract organ inside the 16k-line `epiphany-work` -binary. Do not add another family validator there. Extract these models and -semantic predicates into a dedicated repo-work closure-contract module before -continuing the conversion campaign; an inline namespace or generic policy blob -would merely rearrange the monolith. +models and their family-specific semantic predicates now live in +`epiphany_work/closure_contracts.rs`, not the 16k-line `epiphany-work` command +body. The binary lost 504 lines and now orchestrates parsing/assessment without +owning schema anatomy. The module surface is `pub(super)`: available only to its +parent binary, not promoted into a generic global policy API. New typed closure +families belong in this contract organ when they protect a named family +invariant; do not rebuild generic policy mush. ## Unresolved: provider receipts without chronology diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index 19a0efc6..7b8b6339 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -196,9 +196,10 @@ The confirmed conceptual substitutions have been cut: cannot counterfeit SSH/push/deployment denials. - Verse-query smoke reset proves the exact built-in path and canonical strict containment beneath `.epiphany-smoke` immediately before recursive deletion. -- The four typed closure contract families now form a contiguous organ inside - `epiphany-work`; extract them to a dedicated module before adding more typed - families. Do not replace this with an inline namespace or generic policy blob. +- The four typed closure contract families live in + `epiphany_work/closure_contracts.rs`; `epiphany-work` is their orchestrator. + The module is parent-private and preserves family-specific predicates rather + than exporting generic policy machinery. - Bifrost provider receipt contracts still lack provider timestamp/revision. Do not invent consumer-side ordering; repair that in a Bifrost-owned schema. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index a983a452..9e4c52cd 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index b81a085d..7657712b 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -660,4 +660,4 @@ current_status: - Service lifecycle receipt history is now event-only: `load_epiphany_cultmesh_daemon_service_lifecycle_receipts` filters out the `epiphany-local/daemon-service-lifecycle-receipt/latest` mirror, while `load_latest_epiphany_cultmesh_daemon_service_lifecycle_receipt` remains the latest-state reader. Focused unit test `service_lifecycle_receipt_history_excludes_latest_mirror` proves two per-receipt writes return exactly two history records and latest points at the second. Fresh smoke `verse-query-lifecycle-history-filter-smoke` and live overview/triage `local-20260618-145632-497-efac6f0d` / `local-20260618-145632-321-867947af` prove compact swarm sights still expose service lifecycle attention plus the present elevated runbook artifact without daemon pokes or service mutation. Do not use a broad unscoped cargo test filter for this check on Windows; it fans out across bin harnesses and hit a broken pipe during this pass. - `epiphany-verse-query seed-compact` is the compact seed receipt for wrappers and read-only rites. The older `seed` command still prints the full local Verse context for explicit debugging, but compact wrapper modes now avoid full `seed`/final `query` readback after the combined overview proof exposed Windows debug stack overflow from full-context serialization pressure. last_completed_repo_swarm_cut: Huginn live-fire has crossed the first real repo Body from Persona pressure to branch-local Hands commit and Soul/Mind closure, and now has repeatable closure and redacted-public-proof mouths. On `E:\Projects\Huginn` branch `epiphany/huginn/first-awakening`, `tools/epiphany_local_run.ps1 -Mode repo-persona-intake` accepted item `huginn-inspection-readback-livefire`, Weksa/Persona intake remained sealed, and `epiphany-work derive-plan` lowered it to model-authored safe family `repo.status_section` for `README.md` only. `tools/epiphany_local_run.ps1 -Mode repo-swarm-run` advanced four bounded pulses: run-from-plan, adopt-from-plan, execute-from-plan, and close-from-execute. Huginn commit `e9b07c38fceabbdc89ea35c2156326c80c0393a2` updated only `README.md`; closure receipt `.epiphany\work\work-close-huginn-inspection-readback-livefire.json` records status `closed`, Soul verdict `passed`, Mind state commit `repo-work-close-huginn-inspection-readback-livefire-mind-commit`, safe family `repo.status_section`, path scope `README.md`, Bifrost publication gate, and `privateStateExposed=false`. Verification also ran Huginn's TypeScript compiler through concrete Node path: `C:\Program Files\nodejs\node.exe E:\Projects\Huginn\node_modules\typescript\bin\tsc -p tsconfig.json` passed. Native verifier `epiphany-repo-livefire-closure-smoke --workspace E:\Projects\Huginn --item huginn-inspection-readback-livefire --expected-path README.md --expected-family repo.status_section --expected-gate awaiting-publication --expected-blocker bifrost-publication-missing` checks closure receipt, Mind map entry, overview gate/blocker, authority seals, and `git show` changed paths, returning `status=ok`, `soulVerdict=passed`, `publicationGate=Bifrost`, and `privateStateExposed=false`. Wrapper `tools/epiphany_local_run.ps1 -Mode repo-livefire-closure -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exposes the same read-only proof through the local operator mouth; artifact `local-20260621-190156-803-2f85ba15` printed commit, path, gate, blocker, Soul verdict, Mind commit receipt, and `privateStateExposed=False` without push, merge, publication, or target mutation. New wrapper `tools/epiphany_local_run.ps1 -Mode repo-work-public-proof -Workspace E:\Projects\Huginn -RepoWorkItem huginn-inspection-readback-livefire -SkipBuild` exports the redacted proof bundle and repo-local Verse index without publishing; artifact `local-20260621-190645-345-4555b1dc` wrote `.epiphany\public\proof-bundles\repo-work-public-proof-huginn-inspection-readback-livefire.json`, proof id `repo-work-public-proof-huginn-inspection-readback-livefire`, SHA-256 `857545b199f3e37eb06c2e757e5cfc201958e46667bb1f8403fd333a22620f63`, nine artifact rows, zero publication rows, and `privateStateExposed=False`. swarm overview readback `local-20260621-190701-140-b9519ec6` sees the `REPO-WORK-PUBLIC-PROOF` row and action row from Huginn's repo-local Verse with the same SHA-256 while Bifrost publication remains missing. Launcher compact modes are now named compact operator-context modes instead of read-only modes, and `bifrost-public-proof` summaries print item, target public Verse, room, proof SHA-256, review receipts, and credit receipts so publication receipts are auditable without claiming upstream sync. - next_action: Extract the contiguous typed deployment config/request, secret-policy, and dependency-policy closure contracts from the 16k-line epiphany-work binary into a dedicated repo-work closure-contract module before adding more family validators. Preserve their family-specific semantic predicates; do not create generic policy mush. Then continue the conceptual-substitution pass. Operational/evidence/self-state and operator mirrors follow owned clocks; identity chains are typed; scheduling/runbook selection do not parse prose; verse-query smoke deletion is canonically confined; writerless readiness-review is deleted. Bifrost provider receipts still need provider chronology and artifact/metrics request identity. + next_action: Continue the conceptual-substitution pass. Typed deployment config/request, secret-policy, and dependency-policy contracts now live in parent-private epiphany_work/closure_contracts.rs; add future family validators there only when they protect named invariants, never as generic policy mush. Operational/evidence/self-state and operator mirrors follow owned clocks; identity chains are typed; scheduling/runbook selection do not parse prose; verse-query smoke deletion is canonically confined; writerless readiness-review is deleted. Bifrost provider receipts still need provider chronology and artifact/metrics request identity. Continue auditing remaining substring closure families, destructive path consumers, evidence/security mirrors, and adapters for borrowed authority.