Parse deployment config as typed TOML

This commit is contained in:
Meta Vens 2026-07-13 01:43:27 +01:00
commit af4ff1a773
5 changed files with 248 additions and 74 deletions

View file

@ -87,6 +87,7 @@ 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;
@ -12255,6 +12256,73 @@ fn run_readiness(args: ReadinessArgs) -> Result<Value> {
}))
}
#[derive(Debug, Deserialize)]
struct RepoDeploymentConfig {
schema_version: String,
safe_action_family: String,
private_state_exposed: bool,
deployment: RepoDeploymentSettings,
cultmesh: RepoDeploymentCultMesh,
required_receipts: RepoDeploymentRequiredReceipts,
authority: RepoDeploymentAuthority,
}
#[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<RepoDeploymentConfig> {
toml::from_str(text).context("deployment config is not valid typed TOML")
}
fn run_deployment_config_audit(args: DeploymentConfigAuditArgs) -> Result<Value> {
let workspace = args
.workspace
@ -12271,100 +12339,122 @@ fn run_deployment_config_audit(args: DeploymentConfigAuditArgs) -> Result<Value>
let receipt_path = artifact_dir.join("deployment-config-audit.json");
let generated_at = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
let mut assertions = Vec::new();
let mut config_text = String::new();
let mut parsed_config = None;
if config_path.exists() {
config_text = fs::read_to_string(&config_path)
let config_text = fs::read_to_string(&config_path)
.with_context(|| format!("failed to read {}", config_path.display()))?;
match parse_repo_deployment_config(&config_text) {
Ok(config) => {
push_assertion(
&mut assertions,
"deployment-config-typed-toml",
true,
"Deployment config parses as the typed TOML contract.".to_string(),
);
parsed_config = Some(config);
}
Err(error) => push_assertion(
&mut assertions,
"deployment-config-typed-toml",
false,
format!("Deployment config parse failed: {error:#}"),
),
}
push_assertion(
&mut assertions,
"deployment-config-schema-present",
config_text.contains("schema_version = \"epiphany.repo_deployment_config.v0\""),
parsed_config.as_ref().is_some_and(|config| {
config.schema_version == "epiphany.repo_deployment_config.v0"
}),
"Deployment config carries the schema version.".to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-family-present",
config_text.contains("safe_action_family = \"repo.deployment_config\""),
parsed_config
.as_ref()
.is_some_and(|config| config.safe_action_family == "repo.deployment_config"),
"Deployment config carries the safe action family.".to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-idunn-trigger",
config_text.contains("[deployment]")
&& config_text.contains("enabled = false")
&& config_text.contains("owner = \"Idunn\"")
&& config_text.contains("trigger = \"git-push-observed-by-idunn\"")
&& config_text.contains("watched_ref = \"refs/heads/main\"")
&& config_text.contains("deployment_script_ref = \"deploy/idunn-deploy.ps1\"")
&& config_text.contains("deployment_script_hash_required = true")
&& config_text.contains("deployment_script_review_required = true")
&& config_text.contains("host_access_policy_ref_required = true")
&& config_text.contains("secret_values_embedded = false")
&& config_text.contains("rollback_plan_ref_required = true")
&& config_text.contains("aftercare_checks_required = true")
&& config_text.contains("idunn_receipt_required = true")
&& config_text.contains("aftercare_audit_required = true"),
parsed_config.as_ref().is_some_and(|config| {
let deployment = &config.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
}),
"Deployment config names disabled Idunn git-push trigger, reviewed script/hash, policy, rollback, and aftercare requirements."
.to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-cultmesh-contract",
config_text.contains("[cultmesh]")
&& config_text.contains("local_verse = \"gamecult-local\"")
&& config_text.contains("capability_family = \"gamecult.idunn.deployment\"")
&& config_text
.contains("intent_contract = \"gamecult.idunn.deployment_intent.v0\"")
&& config_text
.contains("receipt_contract = \"gamecult.idunn.deployment_receipt.v0\"")
&& config_text.contains(
"aftercare_contract = \"gamecult.idunn.deployment_aftercare_audit.v0\"",
)
&& config_text.contains("daemon_owns_execution = true"),
parsed_config.as_ref().is_some_and(|config| {
let cultmesh = &config.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
}),
"Deployment config routes execution through Idunn CultMesh contracts.".to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-receipt-contract",
config_text.contains("[required_receipts]")
&& config_text
.contains("mind_adoption = \"epiphany.repo_work_mind_adoption_decision.v0\"")
&& config_text.contains("soul_review = \"epiphany.repo_work_closure_review.v0\"")
&& config_text
.contains("maintainer_review = \"gamecult.maintainer.review_receipt.v0\"")
&& config_text
.contains("secret_policy = \"epiphany.repo_secret_policy_request.v0\"")
&& config_text
.contains("idunn_deployment = \"gamecult.idunn.deployment_receipt.v0\"")
&& config_text.contains(
"aftercare_audit = \"gamecult.idunn.deployment_aftercare_audit.v0\"",
),
parsed_config.as_ref().is_some_and(|config| {
let receipts = &config.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"
}),
"Deployment config names Mind, Soul, maintainer, secret-policy, Idunn deployment, and aftercare receipts."
.to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-authority-seals",
config_text.contains("[authority]")
&& config_text.contains("configuration_only = true")
&& config_text.contains("direct_deployment_authority = false")
&& config_text.contains("direct_ssh_authority = false")
&& config_text.contains("direct_git_push_authority = false")
&& config_text.contains("direct_service_lifecycle_authority = false")
&& config_text.contains("direct_hands_authority = false")
&& config_text.contains("publication_authorized = false")
&& config_text.contains("merge_authorized = false")
&& config_text.contains("cross_body_mutation_authorized = false")
&& config_text.contains("private_verse_rummaging = false")
&& config_text.contains("idunn_deployment_authority_required = true"),
parsed_config.as_ref().is_some_and(|config| {
let authority = &config.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
}),
"Deployment config denies deployment, SSH, git-push, service lifecycle, Hands, publication, merge, and cross-body authority."
.to_string(),
);
push_assertion(
&mut assertions,
"deployment-config-private-seal",
config_text.contains("private_state_exposed = false"),
parsed_config
.as_ref()
.is_some_and(|config| !config.private_state_exposed),
"Deployment config preserves the private-state seal.".to_string(),
);
} else {
@ -12386,7 +12476,10 @@ fn run_deployment_config_audit(args: DeploymentConfigAuditArgs) -> Result<Value>
} else {
"missing"
};
let daemon_owns_execution = all_passed && config_text.contains("daemon_owns_execution = true");
let daemon_owns_execution = all_passed
&& parsed_config
.as_ref()
.is_some_and(|config| config.cultmesh.daemon_owns_execution);
let receipt = json!({
"schemaVersion": "epiphany.repo_deployment_config_audit.v0",
"auditId": "repo-deployment-config-audit",
@ -12439,11 +12532,15 @@ fn run_deployment_execution_runbook(args: DeploymentExecutionRunbookArgs) -> Res
} else {
String::new()
};
let watched_ref = deployment_config_string_value(&config_text, "watched_ref")
.unwrap_or_else(|| "refs/heads/main".to_string());
let deployment_script_ref =
deployment_config_string_value(&config_text, "deployment_script_ref")
.unwrap_or_else(|| "deploy/idunn-deploy.ps1".to_string());
let parsed_config = parse_repo_deployment_config(&config_text).ok();
let watched_ref = parsed_config
.as_ref()
.map(|config| config.deployment.watched_ref.clone())
.unwrap_or_else(|| "missing".to_string());
let deployment_script_ref = parsed_config
.as_ref()
.map(|config| config.deployment.deployment_script_ref.clone())
.unwrap_or_else(|| "missing".to_string());
let current_branch = git_output(&workspace, &["rev-parse", "--abbrev-ref", "HEAD"])?;
let current_commit = git_output(&workspace, &["rev-parse", "HEAD"])?;
let generated_at = Utc::now().to_rfc3339_opts(chrono::SecondsFormat::Secs, true);
@ -15310,6 +15407,79 @@ mod authority_tests {
use epiphany_core::RepoWorkModelingFinding;
use epiphany_core::put_repo_work_modeling_finding;
fn deployment_config_fixture() -> String {
r#"
schema_version = "epiphany.repo_deployment_config.v0"
safe_action_family = "repo.deployment_config"
private_state_exposed = false
[deployment]
enabled = false
owner = "Idunn"
trigger = "git-push-observed-by-idunn"
watched_ref = "refs/heads/main"
deployment_script_ref = "deploy/idunn-deploy.ps1"
deployment_script_hash_required = true
deployment_script_review_required = true
host_access_policy_ref_required = true
secret_values_embedded = false
rollback_plan_ref_required = true
aftercare_checks_required = true
idunn_receipt_required = true
aftercare_audit_required = true
[cultmesh]
local_verse = "gamecult-local"
capability_family = "gamecult.idunn.deployment"
intent_contract = "gamecult.idunn.deployment_intent.v0"
receipt_contract = "gamecult.idunn.deployment_receipt.v0"
aftercare_contract = "gamecult.idunn.deployment_aftercare_audit.v0"
daemon_owns_execution = true
[required_receipts]
mind_adoption = "epiphany.repo_work_mind_adoption_decision.v0"
soul_review = "epiphany.repo_work_closure_review.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
secret_policy = "epiphany.repo_secret_policy_request.v0"
idunn_deployment = "gamecult.idunn.deployment_receipt.v0"
aftercare_audit = "gamecult.idunn.deployment_aftercare_audit.v0"
[authority]
configuration_only = true
direct_deployment_authority = false
direct_ssh_authority = false
direct_git_push_authority = false
direct_service_lifecycle_authority = false
direct_hands_authority = false
publication_authorized = false
merge_authorized = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
idunn_deployment_authority_required = true
"#
.to_string()
}
#[test]
fn deployment_config_uses_typed_toml_not_comment_resemblance() {
let valid = parse_repo_deployment_config(&deployment_config_fixture()).unwrap();
assert_eq!(valid.deployment.watched_ref, "refs/heads/main");
assert!(!valid.authority.direct_git_push_authority);
let counterfeit = deployment_config_fixture().replace(
"direct_git_push_authority = false",
"# direct_git_push_authority = false\ndirect_git_push_authority = true",
);
let parsed = parse_repo_deployment_config(&counterfeit).unwrap();
assert!(parsed.authority.direct_git_push_authority);
let missing_typed_field = deployment_config_fixture().replace(
"watched_ref = \"refs/heads/main\"\n",
"# watched_ref = \"refs/heads/main\"\n",
);
assert!(parse_repo_deployment_config(&missing_typed_field).is_err());
}
#[test]
fn queue_selection_rows_preserve_typed_scheduler_state() {
let overview = EpiphanyCultMeshRepoWorkOverviewEntry {
@ -16077,18 +16247,6 @@ fn compact_text(text: &str, limit: usize) -> String {
truncated
}
fn deployment_config_string_value(text: &str, key: &str) -> Option<String> {
let prefix = format!("{key} = ");
for line in text.lines() {
let trimmed = line.trim();
if let Some(value) = trimmed.strip_prefix(&prefix) {
let value = value.strip_prefix('"')?.strip_suffix('"')?;
return Some(value.to_string());
}
}
None
}
fn read_json(path: &Path) -> Result<Value> {
let raw =
fs::read_to_string(path).with_context(|| format!("failed to read {}", path.display()))?;

View file

@ -715,6 +715,19 @@ route could therefore repair or counterfeit missing ownership. Service lookup
now accepts only the typed field; rows without it cannot produce a runbook
action. A route such as `counterfeit::route` remains prose and nothing more.
## TOML text resemblance substituted for deployment configuration
The operational deployment-config audit validated authority seals, Idunn
ownership, contracts, and required receipts with `text.contains(...)` checks.
The runbook then scraped `watched_ref` and `deployment_script_ref` line-by-line
and silently supplied defaults. Comments, wrong-table keys, or missing values
could therefore resemble a valid config closely enough to steer operational
output. Both paths now consume one deserialized TOML model with typed nested
sections and required fields. Comments cannot override real booleans, missing
fields fail parsing, and the runbook reports missing values rather than
inventing deployment targets. Audit semantics compare the parsed values, not
their textual costume.
## Unresolved: provider receipts without chronology
Bifrost body-change/GitHub publication receipts are externally owned and their

View file

@ -180,6 +180,9 @@ The confirmed conceptual substitutions have been cut:
or hostile strings cannot steer gate, blocker, item, branch, or next move.
- Receipt-directory runbook selection uses typed `service_id` only. It no
longer recovers service ownership by splitting human route prose at `::`.
- Deployment operational audit and runbook read one typed TOML model. Substring
presence, comments, wrong sections, and silent watched-ref/script defaults no
longer substitute for valid deployment configuration.
- Bifrost provider receipt contracts still lack provider timestamp/revision.
Do not invent consumer-side ordering; repair that in a Bifrost-owned schema.

Binary file not shown.

View file

@ -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: Continue the conceptual-substitution modeling pass beyond receipt writers. Operational/evidence/self-state and operator surfaces with owned clocks are event-time ordered; operator receipts bind intents by run identity rather than global chronology; Eve/tool/Bifrost/collaboration projections join chains only by typed identity; repo-work scheduling and service-runbook selection use typed rows/IDs rather than reparsed presentation prose; writerless readiness-review is deleted. Bifrost provider receipts still need provider-owned chronology, and artifact/metrics receipts need explicit repo-work request identity; accounting refuses closure until those contracts exist. Continue auditing other evidence/security mirrors, service configuration claims, adapters, and destructive path consumers for borrowed authority.
next_action: Continue the conceptual-substitution modeling pass beyond receipt writers. Operational/evidence/self-state and operator surfaces with owned clocks are event-time ordered; operator receipts bind intents by run identity rather than global chronology; Eve/tool/Bifrost/collaboration projections join chains only by typed identity; repo-work scheduling and service-runbook selection use typed rows/IDs rather than reparsed presentation prose; deployment operational audit/runbook use typed TOML rather than substring/scraper logic; writerless readiness-review is deleted. Bifrost provider receipts still need provider-owned chronology, and artifact/metrics receipts need explicit repo-work request identity; accounting refuses closure until those contracts exist. Continue auditing remaining closure validators, evidence/security mirrors, service configuration claims, adapters, and destructive path consumers for borrowed authority.