Cut parallel repo-work authority

This commit is contained in:
Meta Vens 2026-07-13 23:33:36 +01:00
commit 15c2e1920c
24 changed files with 408 additions and 20694 deletions

View file

@ -425,7 +425,6 @@ fn run_cli() -> Result<()> {
}
"swarm-brake" | "brake" => {
require_query_bootstrap(&args)?;
let context = query_epiphany_local_verse_context(&args.store, args.runtime_id.clone())?;
let created_at_utc = Utc::now().to_rfc3339();
let status = args
@ -1022,106 +1021,10 @@ fn run_cli() -> Result<()> {
);
}
"bifrost-artifact-acceptance" | "artifact-acceptance" => {
if args.artifact_ref.is_some()
|| args.public_proof_id.is_some()
|| args.result_ref.is_some()
|| args.review_receipts.is_some()
|| args.ledger_entry_id.is_some()
|| args.receipt_id.is_some()
|| args.receipt_status.is_some()
|| args.source_agent_id.is_some()
{
anyhow::bail!(
"bifrost-artifact-acceptance inspects a pending request only; Maintainer owns acceptance decisions and Bifrost owns accounting fields"
);
}
require_query_bootstrap(&args)?;
let (_, map_entries) = load_repo_work_map_entries(&args)?;
let map_entry = latest_repo_work_map_entry_for_family(
&map_entries,
"repo.artifact_acceptance_request",
)
.context(
"bifrost-artifact-acceptance requires a repo.artifact_acceptance_request map entry",
)?;
println!(
"{}",
serde_json::to_string_pretty(&json!({
"schemaVersion": "epiphany.local_verse_bifrost_artifact_acceptance.v0",
"status": "pending-maintainer-bifrost",
"store": args.store,
"runtimeId": args.runtime_id,
"receiptId": null,
"item": map_entry.item,
"sourceWorkspace": map_entry.workspace,
"sourceBranch": map_entry.branch,
"commitSha": map_entry.commit_sha,
"changedPaths": map_entry.changed_paths,
"artifactRef": null,
"publicProofRef": null,
"ledgerEntryId": null,
"reviewReceiptIds": [],
"acceptedBy": null,
"responseOwner": "Maintainer",
"commands": {
"swarmOverview": WRAPPER_OVERVIEW_COMMAND,
"bifrostArtifactAcceptance": WRAPPER_BIFROST_ARTIFACT_ACCEPTANCE_COMMAND,
"bifrostLedger": WRAPPER_BIFROST_LEDGER_COMMAND
},
"privateStateExposed": false,
}))?
);
anyhow::bail!("historical-only: canonical frontier workflow required")
}
"bifrost-metrics" | "metrics-receipt" => {
if args.artifact_ref.is_some()
|| args.verification_receipts.is_some()
|| args.review_receipts.is_some()
|| args.credit_receipt_ids.is_some()
|| args.public_proof_id.is_some()
|| args.result_ref.is_some()
|| args.receipt_summary.is_some()
|| args.receipt_id.is_some()
|| args.receipt_status.is_some()
{
anyhow::bail!(
"bifrost-metrics inspects a pending request only; Bifrost owns accounting fields and Maintainer owns review-load evidence"
);
}
require_query_bootstrap(&args)?;
let (_, map_entries) = load_repo_work_map_entries(&args)?;
let map_entry =
latest_repo_work_map_entry_for_family(&map_entries, "repo.metrics_request")
.context("bifrost-metrics requires a repo.metrics_request map entry")?;
println!(
"{}",
serde_json::to_string_pretty(&json!({
"schemaVersion": "epiphany.local_verse_bifrost_metrics.v0",
"status": "pending-bifrost-maintainer",
"store": args.store,
"runtimeId": args.runtime_id,
"receiptId": null,
"item": map_entry.item,
"sourceWorkspace": map_entry.workspace,
"sourceBranch": map_entry.branch,
"artifactAcceptanceReceiptId": null,
"modelSpendReceiptIds": [],
"reviewLoadReceiptIds": [],
"creditReadbackReceiptIds": [],
"publicProofRef": null,
"metricsSummary": null,
"responseOwner": "Bifrost",
"commands": {
"swarmOverview": WRAPPER_OVERVIEW_COMMAND,
"bifrostMetrics": WRAPPER_BIFROST_METRICS_COMMAND,
"bifrostLedger": WRAPPER_BIFROST_LEDGER_COMMAND
},
"privateStateExposed": false,
}))?
);
anyhow::bail!("historical-only: canonical frontier workflow required")
}
"bifrost-ledger" | "publication-ledger" => {
let report = load_bifrost_ledger_report(&args)?;
@ -3560,6 +3463,8 @@ struct RepoWorkOverviewRow {
#[derive(Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct RepoWorkMapRow {
status: String,
reason: String,
map_entry_id: String,
workspace: String,
item: String,
@ -4757,13 +4662,14 @@ fn repo_work_overview_row(overview: &EpiphanyCultMeshRepoWorkOverviewEntry) -> R
workspace: overview.workspace.clone(),
item: overview.item.clone(),
branch: overview.branch.clone(),
current_gate: overview.current_gate.clone(),
blocker: overview.blocker.clone(),
next_safe_move: overview.next_safe_move.clone(),
current_gate: "historical-only".to_string(),
blocker: "canonical-frontier-workflow-required".to_string(),
next_safe_move: "Canonical frontier workflow required; historical record grants no action."
.to_string(),
changed_path_count: overview.changed_paths.len(),
commit_sha: overview.commit_sha.clone(),
soul_verdict: overview.soul_verdict.clone(),
publication_status: overview.publication_status.clone(),
publication_status: "historical-only".to_string(),
sync_status: overview.sync_status.clone(),
proof_bundle_ref: overview.proof_bundle_ref.clone(),
private_state_exposed: overview.private_state_exposed,
@ -4799,19 +4705,22 @@ fn repo_work_map_rows(
fn repo_work_map_row(entry: &EpiphanyCultMeshRepoWorkMapEntry) -> RepoWorkMapRow {
RepoWorkMapRow {
status: "historical-only".to_string(),
reason: "canonical frontier workflow required".to_string(),
map_entry_id: entry.map_entry_id.clone(),
workspace: entry.workspace.clone(),
item: entry.item.clone(),
branch: entry.branch.clone(),
changed_path_count: entry.changed_paths.len(),
commit_sha: entry.commit_sha.clone(),
safe_action_family: entry.safe_action_family.clone(),
modeling_summary: entry.modeling_summary.clone(),
safe_action_family: format!("historical:{}", entry.safe_action_family),
modeling_summary: "Historical record only; canonical frontier workflow required."
.to_string(),
soul_verdict_receipt_id: entry.soul_verdict_receipt_id.clone(),
mind_gateway_review_id: entry.mind_gateway_review_id.clone(),
mind_state_commit_receipt_id: entry.mind_state_commit_receipt_id.clone(),
publication_gate: entry.publication_gate.clone(),
durable_state_admitted: entry.durable_state_admitted,
publication_gate: "historical-only".to_string(),
durable_state_admitted: false,
source_store_path: entry.source_store_path.clone(),
private_state_exposed: entry.private_state_exposed,
}
@ -4849,19 +4758,19 @@ fn repo_work_map_semantic_rows(
}
fn repo_work_map_semantic_row(entry: &EpiphanyCultMeshRepoWorkMapEntry) -> RepoWorkMapSemanticRow {
let (stage, stage_owner) = repo_work_stage_for_family(&entry.safe_action_family);
RepoWorkMapSemanticRow {
item: entry.item.clone(),
branch: entry.branch.clone(),
stage,
stage_owner,
publication_gate: entry.publication_gate.clone(),
gate_owner: repo_work_gate_owner(&entry.publication_gate),
safe_action_family: entry.safe_action_family.clone(),
stage: "historical-only".to_string(),
stage_owner: "none".to_string(),
publication_gate: "historical-only".to_string(),
gate_owner: "none".to_string(),
safe_action_family: format!("historical:{}", entry.safe_action_family),
changed_path_count: entry.changed_paths.len(),
latest_commit_sha: entry.commit_sha.clone(),
latest_mind_state_commit_receipt_id: entry.mind_state_commit_receipt_id.clone(),
modeling_summary: entry.modeling_summary.clone(),
modeling_summary: "Historical record only; canonical frontier workflow required."
.to_string(),
sight_only: true,
private_state_exposed: entry.private_state_exposed,
}
@ -5408,9 +5317,10 @@ fn repo_work_public_proof_row(
workspace: proof.workspace.clone(),
item: proof.item.clone(),
branch: proof.branch.clone(),
current_gate: proof.current_gate.clone(),
blocker: proof.blocker.clone(),
next_safe_move: proof.next_safe_move.clone(),
current_gate: "historical-only".to_string(),
blocker: "canonical-frontier-workflow-required".to_string(),
next_safe_move: "Canonical frontier workflow required; historical record grants no action."
.to_string(),
changed_path_count: proof.changed_paths.len(),
commit_sha: proof.commit_sha.clone(),
soul_verdict: proof.soul_verdict.clone(),
@ -5460,18 +5370,18 @@ fn repo_work_readiness_row(
readiness_id: report.readiness_id.clone(),
workspace: report.workspace.clone(),
item: report.item.clone(),
status: report.status.clone(),
missing_required_count: report.missing_required_count,
satisfied_required_count: report.satisfied_required_count,
status: "historical-only".to_string(),
missing_required_count: 1,
satisfied_required_count: 0,
readiness_receipt_ref: report.readiness_receipt_ref.clone(),
overview_receipt_ref: report.overview_receipt_ref.clone(),
proof_bundle_id: report.proof_bundle_id.clone(),
missing_kinds: report.missing_kinds.clone(),
sight_only: report.sight_only,
readiness_approval_authorized: report.readiness_approval_authorized,
publication_authorized: report.publication_authorized,
service_lifecycle_authority: report.service_lifecycle_authority,
hands_action_authorized: report.hands_action_authorized,
missing_kinds: vec!["canonical-frontier-workflow-required".to_string()],
sight_only: true,
readiness_approval_authorized: false,
publication_authorized: false,
service_lifecycle_authority: false,
hands_action_authorized: false,
private_state_exposed: report.private_state_exposed,
}
}
@ -6125,21 +6035,6 @@ fn load_repo_work_map_entries(
Ok((latest_repo_work_map_entry, repo_work_map_entries))
}
fn latest_repo_work_map_entry_for_family(
entries: &[EpiphanyCultMeshRepoWorkMapEntry],
family: &str,
) -> Option<EpiphanyCultMeshRepoWorkMapEntry> {
entries
.iter()
.filter(|entry| entry.safe_action_family == family)
.max_by(|left, right| {
left.admitted_at
.cmp(&right.admitted_at)
.then_with(|| left.map_entry_id.cmp(&right.map_entry_id))
})
.cloned()
}
fn load_repo_work_public_proofs(
args: &Args,
) -> Result<(
@ -6447,19 +6342,19 @@ fn load_swarm_overview_report(args: &Args) -> Result<SwarmOverviewReport> {
let (repo_work_map_semantic_rows, repo_work_map_semantic_tui_rows) =
repo_work_map_semantic_rows(&repo_work_map_entries);
let (repo_work_map_family_lens_rows, repo_work_map_family_lens_tui_rows) =
repo_work_map_family_lens_rows(&repo_work_map_entries);
repo_work_map_family_lens_rows(&[]);
let (repo_work_map_path_lens_rows, repo_work_map_path_lens_tui_rows) =
repo_work_map_path_lens_rows(&repo_work_map_entries);
repo_work_map_path_lens_rows(&[]);
let (repo_work_map_branch_lens_rows, repo_work_map_branch_lens_tui_rows) =
repo_work_map_branch_lens_rows(&repo_work_map_entries);
repo_work_map_branch_lens_rows(&[]);
let (repo_work_map_stage_lens_rows, repo_work_map_stage_lens_tui_rows) =
repo_work_map_stage_lens_rows(&repo_work_map_entries);
repo_work_map_stage_lens_rows(&[]);
let (repo_work_map_gate_lens_rows, repo_work_map_gate_lens_tui_rows) =
repo_work_map_gate_lens_rows(&repo_work_map_entries);
repo_work_map_gate_lens_rows(&[]);
let (repo_work_map_closure_rows, repo_work_map_closure_tui_rows) =
repo_work_map_closure_rows(&repo_work_map_entries);
repo_work_map_closure_rows(&[]);
let (repo_work_map_acceptance_rows, repo_work_map_acceptance_tui_rows) =
repo_work_map_acceptance_rows(&repo_work_map_entries);
repo_work_map_acceptance_rows(&[]);
let (repo_work_public_proof_rows, repo_work_public_proof_tui_rows) =
repo_work_public_proof_rows(&repo_work_public_proofs);
let (repo_work_readiness_rows, repo_work_readiness_tui_rows) =
@ -6476,9 +6371,9 @@ fn load_swarm_overview_report(args: &Args) -> Result<SwarmOverviewReport> {
&service_lifecycle_attention_rows,
&service_execution_failed_check_rows,
&service_execution_runbook_actions,
&repo_work_overviews,
&repo_work_public_proofs,
&repo_work_readiness_reports,
&[],
&[],
&[],
);
let private_state_exposed = daemon_report
.rows
@ -6542,13 +6437,13 @@ fn load_swarm_overview_report(args: &Args) -> Result<SwarmOverviewReport> {
.map(|entry| entry.map_entry_id.clone());
let latest_repo_work_gate = latest_repo_work_overview
.as_ref()
.map(|overview| overview.current_gate.clone());
.map(|_| "historical-only".to_string());
let latest_repo_work_blocker = latest_repo_work_overview
.as_ref()
.map(|overview| overview.blocker.clone());
let latest_repo_work_next_safe_move = latest_repo_work_overview
.as_ref()
.map(|overview| overview.next_safe_move.clone());
.map(|_| "canonical-frontier-workflow-required".to_string());
let latest_repo_work_next_safe_move = latest_repo_work_overview.as_ref().map(|_| {
"Canonical frontier workflow required; historical record grants no action.".to_string()
});
let latest_repo_work_public_proof = latest_repo_work_public_proof
.as_ref()
.map(|proof| proof.public_proof_id.clone());
@ -7740,8 +7635,6 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
&args.store,
args.runtime_id.clone(),
)?;
let repo_work_map_entries =
load_epiphany_cultmesh_repo_work_map_entries(&args.store, args.runtime_id.clone())?;
Ok(bifrost_ledger_report(
arrival_latest_intent.as_ref(),
arrival_latest_publication.as_ref(),
@ -7751,7 +7644,7 @@ fn load_bifrost_ledger_report(args: &Args) -> Result<BifrostLedgerReport> {
arrival_latest_metrics.as_ref(),
arrival_latest_feedback.as_ref(),
latest_consensus.as_ref(),
&repo_work_map_entries,
&[],
))
}
@ -7768,7 +7661,7 @@ fn bifrost_ledger_report(
arrival_latest_metrics: Option<&EpiphanyCultMeshBifrostMetricsReceiptEntry>,
arrival_latest_feedback: Option<&EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
latest_consensus: Option<&EpiphanyCultMeshImaginationConsensusReceiptEntry>,
repo_work_map_entries: &[EpiphanyCultMeshRepoWorkMapEntry],
_repo_work_map_entries: &[EpiphanyCultMeshRepoWorkMapEntry],
) -> BifrostLedgerReport {
let mut rows = Vec::new();
let mut tui_rows = Vec::new();
@ -7934,7 +7827,6 @@ fn bifrost_ledger_report(
arrival_latest_metrics,
arrival_latest_feedback,
latest_consensus,
repo_work_map_entries,
);
let closed_accounting_row_count = accounting_rows
.iter()
@ -7983,13 +7875,7 @@ fn bifrost_ledger_report(
arrival_latest_feedback_id: arrival_latest_feedback
.map(|feedback| feedback.feedback_id.clone()),
latest_consensus_receipt_id: latest_consensus.map(|receipt| receipt.receipt_id.clone()),
repo_work_accounting_request_count: repo_work_map_entries
.iter()
.filter(|entry| {
entry.safe_action_family == "repo.artifact_acceptance_request"
|| entry.safe_action_family == "repo.metrics_request"
})
.count(),
repo_work_accounting_request_count: 0,
private_state_exposed,
}
}
@ -8029,7 +7915,6 @@ fn bifrost_accounting_rows(
arrival_latest_metrics: Option<&EpiphanyCultMeshBifrostMetricsReceiptEntry>,
arrival_latest_feedback: Option<&EpiphanyCultMeshBifrostCollaborationFeedbackEntry>,
latest_consensus: Option<&EpiphanyCultMeshImaginationConsensusReceiptEntry>,
repo_work_map_entries: &[EpiphanyCultMeshRepoWorkMapEntry],
) -> (Vec<BifrostAccountingRow>, Vec<String>) {
let mut rows = Vec::new();
let mut tui_rows = Vec::new();
@ -8157,15 +8042,9 @@ fn bifrost_accounting_rows(
push_artifact_acceptance_accounting_row(
&mut rows,
&mut tui_rows,
repo_work_map_entries,
arrival_latest_artifact_acceptance,
);
push_metrics_accounting_row(
&mut rows,
&mut tui_rows,
repo_work_map_entries,
arrival_latest_metrics,
);
push_metrics_accounting_row(&mut rows, &mut tui_rows, arrival_latest_metrics);
let matching_consensus = arrival_latest_feedback.and_then(|feedback| {
latest_consensus.filter(|receipt| receipt.feedback_id == feedback.feedback_id)
@ -8222,44 +8101,18 @@ fn bifrost_accounting_rows(
fn push_artifact_acceptance_accounting_row(
rows: &mut Vec<BifrostAccountingRow>,
tui_rows: &mut Vec<String>,
repo_work_map_entries: &[EpiphanyCultMeshRepoWorkMapEntry],
latest_receipt: Option<&EpiphanyCultMeshBifrostArtifactAcceptanceReceiptEntry>,
) {
let matching = repo_work_map_entries
.iter()
.filter(|entry| entry.safe_action_family == "repo.artifact_acceptance_request")
.collect::<Vec<_>>();
let latest_request = matching.iter().copied().max_by(|left, right| {
left.admitted_at
.cmp(&right.admitted_at)
.then_with(|| left.map_entry_id.cmp(&right.map_entry_id))
});
let request_private = latest_request
.map(|entry| entry.private_state_exposed)
.unwrap_or(false);
let receipt_private = latest_receipt
.map(|receipt| receipt.private_state_exposed)
.unwrap_or(false);
let review_receipt_count = latest_receipt
.map(|receipt| receipt.maintainer_review_receipt_ids.len())
.or_else(|| {
latest_request.map(|entry| {
[
&entry.soul_verdict_receipt_id,
&entry.mind_gateway_review_id,
&entry.mind_state_commit_receipt_id,
]
.iter()
.filter(|receipt| !receipt.trim().is_empty() && receipt.as_str() != "none")
.count()
})
})
.unwrap_or(0);
let public_artifact_count = latest_receipt
.map(|receipt| receipt.changed_paths.len())
.or_else(|| latest_request.map(|entry| entry.changed_paths.len()))
.unwrap_or(0);
let private = request_private || receipt_private;
let private = receipt_private;
let receipt_proof_complete = latest_receipt
.map(|receipt| {
!receipt.artifact_ref.trim().is_empty()
@ -8278,13 +8131,12 @@ fn push_artifact_acceptance_accounting_row(
lane: "artifact-acceptance-request".to_string(),
owner: "Bifrost".to_string(),
status: bifrost_accounting_status(
false,
latest_request.is_some() || latest_receipt.is_some(),
receipt_proof_complete,
latest_receipt.is_some(),
private,
),
closure: format!(
"request={} acceptance={} requestIdentity=missing receiptProof={} review={} artifacts={}",
present_word(latest_request.is_some()),
"acceptance={} receiptProof={} review={} artifacts={}",
present_word(latest_receipt.is_some()),
if receipt_proof_complete {
"complete"
@ -8296,23 +8148,12 @@ fn push_artifact_acceptance_accounting_row(
),
ledger_entry_id: latest_receipt
.map(|receipt| receipt.bifrost_ledger_entry_id.clone())
.or_else(|| latest_request.map(|entry| entry.publication_gate.clone()))
.unwrap_or_else(|| "none".to_string()),
latest_receipt_id: latest_receipt
.map(|receipt| receipt.receipt_id.clone())
.or_else(|| latest_request.map(|entry| entry.mind_state_commit_receipt_id.clone()))
.unwrap_or_else(|| "none".to_string()),
public_ref: latest_receipt
.map(|receipt| receipt.public_proof_ref.clone())
.or_else(|| {
latest_request.map(|entry| {
if entry.commit_sha.trim().is_empty() || entry.commit_sha == "none" {
entry.branch.clone()
} else {
entry.commit_sha.clone()
}
})
})
.unwrap_or_else(|| "none".to_string()),
review_receipt_count,
credit_receipt_count: 0,
@ -8325,21 +8166,8 @@ fn push_artifact_acceptance_accounting_row(
fn push_metrics_accounting_row(
rows: &mut Vec<BifrostAccountingRow>,
tui_rows: &mut Vec<String>,
repo_work_map_entries: &[EpiphanyCultMeshRepoWorkMapEntry],
latest_receipt: Option<&EpiphanyCultMeshBifrostMetricsReceiptEntry>,
) {
let matching = repo_work_map_entries
.iter()
.filter(|entry| entry.safe_action_family == "repo.metrics_request")
.collect::<Vec<_>>();
let latest_request = matching.iter().copied().max_by(|left, right| {
left.admitted_at
.cmp(&right.admitted_at)
.then_with(|| left.map_entry_id.cmp(&right.map_entry_id))
});
let request_private = latest_request
.map(|entry| entry.private_state_exposed)
.unwrap_or(false);
let receipt_private = latest_receipt
.map(|receipt| receipt.private_state_exposed)
.unwrap_or(false);
@ -8352,28 +8180,9 @@ fn push_metrics_accounting_row(
let credit_count = latest_receipt
.map(|receipt| receipt.credit_readback_receipt_ids.len())
.unwrap_or(0);
let public_artifact_count = latest_receipt
.map(|_| 1)
.or_else(|| latest_request.map(|entry| entry.changed_paths.len()))
.unwrap_or(0);
let request_review_count = latest_request
.map(|entry| {
[
&entry.soul_verdict_receipt_id,
&entry.mind_gateway_review_id,
&entry.mind_state_commit_receipt_id,
]
.iter()
.filter(|receipt| !receipt.trim().is_empty() && receipt.as_str() != "none")
.count()
})
.unwrap_or(0);
let review_receipt_count = if latest_receipt.is_some() {
model_spend_count + review_load_count
} else {
request_review_count
};
let private = request_private || receipt_private;
let public_artifact_count = latest_receipt.map(|_| 1).unwrap_or(0);
let review_receipt_count = model_spend_count + review_load_count;
let private = receipt_private;
let receipt_proof_complete = latest_receipt
.map(|receipt| {
!receipt.artifact_acceptance_receipt_id.trim().is_empty()
@ -8418,13 +8227,12 @@ fn push_metrics_accounting_row(
lane: "metrics-request".to_string(),
owner: "Bifrost".to_string(),
status: bifrost_accounting_status(
false,
latest_request.is_some() || latest_receipt.is_some(),
receipt_proof_complete,
latest_receipt.is_some(),
private,
),
closure: format!(
"request={} metrics={} requestIdentity=missing receiptProof={} modelSpend={} reviewLoad={} credit={}",
present_word(latest_request.is_some()),
"metrics={} receiptProof={} modelSpend={} reviewLoad={} credit={}",
present_word(latest_receipt.is_some()),
if receipt_proof_complete {
"complete"
@ -8435,24 +8243,14 @@ fn push_metrics_accounting_row(
review_load_count,
credit_count
),
ledger_entry_id: latest_request
.map(|entry| entry.publication_gate.clone())
ledger_entry_id: latest_receipt
.map(|receipt| receipt.artifact_acceptance_receipt_id.clone())
.unwrap_or_else(|| "none".to_string()),
latest_receipt_id: latest_receipt
.map(|receipt| receipt.receipt_id.clone())
.or_else(|| latest_request.map(|entry| entry.mind_state_commit_receipt_id.clone()))
.unwrap_or_else(|| "none".to_string()),
public_ref: latest_receipt
.map(|receipt| receipt.public_proof_ref.clone())
.or_else(|| {
latest_request.map(|entry| {
if entry.commit_sha.trim().is_empty() || entry.commit_sha == "none" {
entry.branch.clone()
} else {
entry.commit_sha.clone()
}
})
})
.unwrap_or_else(|| "none".to_string()),
review_receipt_count,
credit_receipt_count: credit_count,
@ -10056,7 +9854,6 @@ mod lifecycle_projection_tests {
None,
None,
None,
&[],
);
assert_eq!(matching[0].status, "closed");
@ -10071,7 +9868,6 @@ mod lifecycle_projection_tests {
None,
None,
None,
&[],
);
assert_eq!(mismatched[0].status, "open");
assert!(mismatched[0].closure.contains("publication=missing"));
@ -10091,7 +9887,6 @@ mod lifecycle_projection_tests {
None,
Some(&feedback),
Some(&matching_consensus),
&[],
);
assert_eq!(matching.last().unwrap().status, "closed");
@ -10105,7 +9900,6 @@ mod lifecycle_projection_tests {
None,
Some(&feedback),
Some(&unrelated_consensus),
&[],
);
let row = mismatched.last().unwrap();
assert_eq!(row.status, "open");
@ -10114,48 +9908,33 @@ mod lifecycle_projection_tests {
}
#[test]
fn request_accounting_stays_open_without_typed_receipt_identity() {
let old_private = repo_request("repo.artifact_acceptance_request", "old", true);
let mut current = repo_request("repo.artifact_acceptance_request", "current", false);
current.admitted_at = "2026-07-13T01:00:00Z".to_string();
fn receipt_accounting_ignores_historical_repo_work_requests() {
let historical = repo_request("repo.artifact_acceptance_request", "old", true);
let artifact = artifact_receipt();
let mut rows = Vec::new();
let mut tui = Vec::new();
push_artifact_acceptance_accounting_row(
&mut rows,
&mut tui,
&[old_private, current],
Some(&artifact),
);
assert_eq!(rows[0].status, "open");
assert!(rows[0].closure.contains("requestIdentity=missing"));
assert!(rows[0].closure.contains("receiptProof=complete"));
assert!(!rows[0].private_state_exposed);
let request = repo_request("repo.metrics_request", "metrics", false);
let metrics = metrics_receipt();
rows.clear();
tui.clear();
push_metrics_accounting_row(
&mut rows,
&mut tui,
std::slice::from_ref(&request),
let (rows, _) = bifrost_accounting_rows(
None,
None,
None,
None,
Some(&artifact),
Some(&metrics),
None,
None,
);
assert_eq!(rows[0].status, "open");
assert!(rows[0].closure.contains("requestIdentity=missing"));
assert!(rows[0].closure.contains("receiptProof=complete"));
assert_eq!(rows.iter().filter(|row| row.status == "closed").count(), 2);
assert!(
rows.iter()
.any(|row| row.lane == "artifact-acceptance-request")
);
assert!(rows.iter().any(|row| row.lane == "metrics-request"));
assert!(historical.private_state_exposed);
let mut incomplete_metrics = metrics_receipt();
incomplete_metrics.token_summary_ref = None;
rows.clear();
tui.clear();
push_metrics_accounting_row(
&mut rows,
&mut tui,
std::slice::from_ref(&request),
Some(&incomplete_metrics),
);
let mut rows = Vec::new();
let mut tui = Vec::new();
push_metrics_accounting_row(&mut rows, &mut tui, Some(&incomplete_metrics));
assert_eq!(rows[0].status, "open");
assert!(rows[0].closure.contains("receiptProof=incomplete"));
}

File diff suppressed because it is too large Load diff

View file

@ -1,5 +0,0 @@
include!("closure_contracts/external_governance.rs");
include!("closure_contracts/collaboration.rs");
include!("closure_contracts/preparation.rs");
include!("closure_contracts/workflow.rs");
include!("closure_contracts/operations.rs");

View file

@ -1,196 +0,0 @@
#[derive(Debug, Deserialize)]
pub(super) struct RepoCollaborationPolicy {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
policy: CollaborationPolicyProposal,
body: CollaborationBody,
verses: std::collections::BTreeMap<String, toml::Value>,
eve: CollaborationEve,
persona: std::collections::BTreeMap<String, bool>,
imagination: CollaborationImagination,
authority: std::collections::BTreeMap<String, bool>,
}
impl RepoCollaborationPolicy {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_collaboration_policy.v0"
&& self.safe_action_family == "repo.collaboration_policy"
}
pub(super) fn remains_proposal(&self) -> bool {
self.policy.status == "proposed"
&& self.policy.authoring_owner == "Imagination"
&& self.policy.required_reviewers == ["Persona", "Mind"]
&& !self.policy.policy_admitted
&& self.policy.publication_owner == "Bifrost"
}
pub(super) fn preserves_provider_truth(&self) -> bool {
self.body.provider_owns_truth && !self.body.renderer_owns_truth
}
pub(super) fn has_verse_boundaries(&self) -> bool {
self.verses.get("private").and_then(toml::Value::as_str) == Some("epiphany-internal")
&& self.verses.get("local").and_then(toml::Value::as_str) == Some("gamecult-local")
&& self.verses.get("public").and_then(toml::Value::as_str) == Some("epiphany-global")
&& self
.verses
.get("private_state_may_leave_repo")
.and_then(toml::Value::as_bool)
== Some(false)
&& self
.verses
.get("odin_discoverable")
.and_then(toml::Value::as_bool)
== Some(true)
}
pub(super) fn has_eve_request(&self) -> bool {
self.eve.surface.starts_with("eve://epiphany/repo/")
&& self.eve.compact_tui_required
&& self.eve.connection_receipt_required
&& self.eve.supported_actions == ["read-queue", "discuss", "submit-feedback"]
}
pub(super) fn has_persona_route(&self) -> bool {
[
"public_discussion_allowed",
"human_discussion_allowed",
"peer_persona_discussion_allowed",
"speech_audit_required",
"feedback_must_route_to_imagination",
]
.iter()
.all(|key| self.persona.get(*key) == Some(&true))
}
pub(super) fn has_imagination_route(&self) -> bool {
self.imagination
.feedback_route
.starts_with("imagination://repo/")
&& self.imagination.consensus_required_before_adoption
&& self.imagination.candidate_actions_non_authoritative
&& self.imagination.mind_adoption_required
&& self.imagination.bifrost_publication_required
}
pub(super) fn has_authority_seals(&self) -> bool {
[
"direct_hands_authority",
"direct_mind_state_commit",
"direct_publication_authority",
"direct_merge_authority",
"service_lifecycle_authority",
"cross_body_mutation_authority",
"private_verse_rummaging",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&false))
&& self.authority.get("requires_cultmesh_receipts") == Some(&true)
}
}
#[derive(Debug, Deserialize)]
struct CollaborationPolicyProposal {
status: String,
authoring_owner: String,
required_reviewers: Vec<String>,
policy_admitted: bool,
publication_owner: String,
}
#[derive(Debug, Deserialize)]
struct CollaborationBody {
provider_owns_truth: bool,
renderer_owns_truth: bool,
}
#[derive(Debug, Deserialize)]
struct CollaborationEve {
surface: String,
compact_tui_required: bool,
connection_receipt_required: bool,
supported_actions: Vec<String>,
}
#[derive(Debug, Deserialize)]
struct CollaborationImagination {
feedback_route: String,
consensus_required_before_adoption: bool,
candidate_actions_non_authoritative: bool,
mind_adoption_required: bool,
bifrost_publication_required: bool,
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoCollaborationTopic {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
topic: CollaborationTopicProposal,
imagination: CollaborationTopicImagination,
authority: std::collections::BTreeMap<String, bool>,
}
impl RepoCollaborationTopic {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_collaboration_topic.v0"
&& self.safe_action_family == "repo.collaboration_topic"
}
pub(super) fn remains_unpublished_proposal(&self) -> bool {
let t = &self.topic;
t.status == "proposed"
&& t.authoring_owner == "Imagination"
&& t.discussion_owner == "Persona"
&& t.publication_owner == "Bifrost"
&& t.requested_public_room
.starts_with("epiphany-global/persona-collaboration/")
&& t.requested_eve_surface.starts_with("eve://epiphany/repo/")
&& !t.public_room_published
&& !t.eve_surface_published
&& t.provider_receipt_required
&& t.persona_discussion_allowed
&& t.human_discussion_allowed
}
pub(super) fn has_imagination_route(&self) -> bool {
self.imagination
.consensus_route
.starts_with("imagination://repo/")
&& self.imagination.consensus_required_before_action
&& self.imagination.candidate_actions_are_non_authoritative
&& self.imagination.mind_adoption_required
&& self.imagination.bifrost_publication_required
}
pub(super) fn has_authority_seals(&self) -> bool {
[
"adoption_authorized",
"hands_action_authorized",
"publication_authorized",
"cross_body_mutation_authorized",
"private_verse_rummaging",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&false))
}
}
#[derive(Debug, Deserialize)]
struct CollaborationTopicProposal {
status: String,
authoring_owner: String,
discussion_owner: String,
publication_owner: String,
requested_public_room: String,
requested_eve_surface: String,
public_room_published: bool,
eve_surface_published: bool,
provider_receipt_required: bool,
persona_discussion_allowed: bool,
human_discussion_allowed: bool,
}
#[derive(Debug, Deserialize)]
struct CollaborationTopicImagination {
consensus_route: String,
consensus_required_before_action: bool,
candidate_actions_are_non_authoritative: bool,
mind_adoption_required: bool,
bifrost_publication_required: bool,
}
pub(super) fn parse_repo_collaboration_policy(text: &str) -> Result<RepoCollaborationPolicy> {
toml::from_str(text).context("collaboration policy is not valid typed TOML")
}
pub(super) fn parse_repo_collaboration_topic(text: &str) -> Result<RepoCollaborationTopic> {
toml::from_str(text).context("collaboration topic is not valid typed TOML")
}
include!("collaboration_tests.rs");

View file

@ -1,41 +0,0 @@
#[cfg(test)]
mod collaboration_tests {
use super::*;
#[test]
fn topic_comment_cannot_counterfeit_publication_state() {
let text = r#"
schema_version = "epiphany.repo_collaboration_topic.v0"
safe_action_family = "repo.collaboration_topic"
summary = "summary"
private_state_exposed = false
[topic]
status = "proposed"
authoring_owner = "Imagination"
discussion_owner = "Persona"
publication_owner = "Bifrost"
requested_public_room = "epiphany-global/persona-collaboration/item"
requested_eve_surface = "eve://epiphany/repo/item/collaboration"
# public_room_published = false
public_room_published = true
eve_surface_published = false
provider_receipt_required = true
persona_discussion_allowed = true
human_discussion_allowed = true
[imagination]
consensus_route = "imagination://repo/item/consensus-discovery"
consensus_required_before_action = true
candidate_actions_are_non_authoritative = true
mind_adoption_required = true
bifrost_publication_required = true
[authority]
adoption_authorized = false
hands_action_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
"#;
let topic = parse_repo_collaboration_topic(text).expect("fixture is typed TOML");
assert!(!topic.remains_unpublished_proposal());
}
}

View file

@ -1,485 +0,0 @@
#[cfg(test)]
mod external_governance_tests {
use super::*;
#[test]
fn readiness_comment_cannot_counterfeit_approval_seal() {
let text = r#"
schema_version = "epiphany.repo_readiness_review_request.v0"
safe_action_family = "repo.readiness_review_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-mvp-readiness-review"
routing_owner = "Self"
required_reviewers = ["Maintainer", "Soul", "Mind", "Bifrost"]
readiness_approval_owner = "Maintainer"
requested_effect = "review-redacted-repo-swarm-mvp-proof-bundle"
maintainer_readiness_acceptance_required = true
bifrost_publication_review_required = true
[antecedents]
[required_receipts]
[readiness_packet]
requires_proof_bundle_ref = false
requires_changed_path_list = false
requires_branch_name = false
requires_upstream_main_ref = false
requires_public_proof_ref = false
requires_bifrost_ledger_ref = false
requires_idunn_lifecycle_ref = false
requires_tool_directory_ref = false
requires_redaction_report = false
requires_reviewer_identity = false
allowed_verdicts = []
[authority]
# readiness_approval_authorized = false
readiness_approval_authorized = true
"#;
let request = parse_repo_readiness_review_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn comment_cannot_counterfeit_direct_execution_seal() {
let text = r#"
schema_version = "epiphany.repo_tool_request.v0"
safe_action_family = "repo.tool_request"
summary = "summary"
private_state_exposed = false
[request]
requester_body = "repo:test"
routing_owner = "Self"
pressure_source = "Persona"
target_directory = "gamecult-local/daemon-tool-directory"
target_capability = "daemon-tool-capability:selected-by-review"
operation = "submitTypedToolIntent"
[cultmesh]
intent_contract = "epiphany.cultmesh.daemon_tool_invocation_intent.v0"
receipt_contract = "epiphany.cultmesh.daemon_tool_invocation_receipt.v0"
host_daemon_owns_execution = true
requester_owns_execution = false
requires_host_liveness_ready = true
requires_cultmesh_receipts = true
[odin]
discoverable = true
preserves_provider_ownership = true
private_verse_passthrough = false
[authority]
# direct_tool_execution = false
direct_tool_execution = true
arbitrary_shell_authority = false
hands_action_authority = false
state_commit_authority = false
publication_authority = false
service_lifecycle_authority = false
cross_body_mutation_authority = false
private_verse_rummaging = false
"#;
let request = parse_repo_tool_request(text).expect("fixture is typed TOML");
assert!(request.authority.direct_tool_execution);
assert!(!request.has_authority_seals());
}
#[test]
fn metrics_comment_cannot_counterfeit_spend_seal() {
let text = r#"
schema_version = "epiphany.repo_metrics_request.v0"
safe_action_family = "repo.metrics_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-metrics-review"
routing_owner = "Self"
accounting_owner = "Bifrost"
review_evidence_owner = "Maintainer"
spend_receipt_required = true
review_load_receipt_required = true
requested_effect = "record-compute-review-and-artifact-accounting"
publication_request_ref = "publication"
credit_request_ref = "credit"
artifact_acceptance_request_ref = "artifact"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_required = true
accepted_artifact_required = true
credit_request_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
accepted_artifact = "gamecult.artifact.acceptance_receipt.v0"
model_spend = "gamecult.metrics.model_spend_receipt.v0"
review_load = "gamecult.metrics.review_load_receipt.v0"
credit_readback = "gamecult.bifrost.credit_readback_receipt.v0"
[metrics_packet]
requires_model_call_count = true
requires_token_summary = true
requires_cost_availability_status = true
requires_review_duration = true
requires_review_event_count = true
requires_accepted_artifact_ref = true
requires_public_proof_ref = true
requires_credit_readback_ref = true
requires_private_state_redaction_check = true
[authority]
branch_local_only = true
metrics_ledger_authorized = false
# spend_authorized = false
spend_authorized = true
review_load_authorized = false
credit_ledger_authorized = false
github_pr_authorized = false
merge_authorized = false
publication_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
bifrost_accounting_required = true
maintainer_review_evidence_required = true
"#;
let request = parse_repo_metrics_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn artifact_comment_cannot_counterfeit_acceptance_seal() {
let text = r#"
schema_version = "epiphany.repo_artifact_acceptance_request.v0"
safe_action_family = "repo.artifact_acceptance_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-artifact-acceptance-review"
routing_owner = "Self"
acceptance_owner = "Maintainer"
accounting_owner = "Bifrost"
acceptance_receipt_required = true
requested_effect = "record-accepted-artifact-for-reviewed-branch-work"
verification_request_ref = "verification"
maintainer_review_request_ref = "review"
publication_request_ref = "publication"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_required = true
maintainer_review_required = true
hands_commit_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
hands_commit = "epiphany.hands.commit_receipt"
accepted_artifact = "gamecult.artifact.acceptance_receipt.v0"
[artifact_packet]
requires_artifact_ref = true
requires_commit_sha = true
requires_changed_path_list = true
requires_review_verdict = true
requires_public_proof_ref = true
requires_acceptance_rationale = true
requires_private_state_redaction_check = true
[authority]
branch_local_only = true
# artifact_acceptance_authorized = false
artifact_acceptance_authorized = true
credit_ledger_authorized = false
github_pr_authorized = false
merge_authorized = false
publication_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
maintainer_acceptance_authority_required = true
bifrost_accounting_required = true
"#;
let request = parse_repo_artifact_acceptance_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn credit_comment_cannot_counterfeit_ledger_seal() {
let text = r#"
schema_version = "epiphany.repo_credit_request.v0"
safe_action_family = "repo.credit_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-bifrost-credit-review"
requested_owner = "Bifrost"
requested_effect = "record-credit-for-redacted-proof-and-accepted-artifact"
publication_request_ref = "publication"
maintainer_review_request_ref = "review"
pr_request_ref = "pr"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_required = true
maintainer_review_required = true
accepted_artifact_required = true
authorship_context_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
accepted_artifact = "gamecult.artifact.acceptance_receipt.v0"
credit_ledger = "gamecult.bifrost.credit_receipt.v0"
credit_readback = "gamecult.bifrost.credit_readback_receipt.v0"
[credit_packet]
requires_author_identity = true
requires_reviewer_identity = true
requires_accepted_artifact_ref = true
requires_public_proof_ref = true
requires_changed_path_list = true
requires_credit_ledger_target = true
requires_private_state_redaction_check = true
[authority]
branch_local_only = true
# credit_ledger_authorized = false
credit_ledger_authorized = true
bifrost_publication_authorized = false
github_pr_authorized = false
merge_authorized = false
publication_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
bifrost_credit_authority_required = true
"#;
let request = parse_repo_credit_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn publication_comment_cannot_counterfeit_bifrost_seal() {
let text = r#"
schema_version = "epiphany.repo_publication_request.v0"
safe_action_family = "repo.publication_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-bifrost-review"
requested_owner = "Bifrost"
requested_effect = "publish-redacted-proof-and-route-maintainer-review"
verification_request_ref = "verification"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_export_required = true
private_state_redaction_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
bifrost_publication = "gamecult.bifrost.public_proof_publication_receipt.v0"
github_publication = "gamecult.github.publication_receipt.v0"
credit_ledger = "gamecult.bifrost.credit_receipt.v0"
upstream_sync = "epiphany.repo_work_upstream_main_sync.v0"
[public_export]
redacted_only = true
raw_receipts_allowed = false
private_paths_allowed = false
worker_thought_allowed = false
operator_context_allowed = false
credit_required = true
[authority]
branch_local_only = true
# bifrost_publication_authorized = false
bifrost_publication_authorized = true
github_publication_authorized = false
credit_ledger_authorized = false
merge_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
maintainer_review_required = true
"#;
let request = parse_repo_publication_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn sync_comment_cannot_counterfeit_push_seal() {
let text = r#"
schema_version = "epiphany.repo_sync_request.v0"
safe_action_family = "repo.sync_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-upstream-main-proof"
proof_owner = "Bifrost"
requested_effect = "prove-published-commit-contained-by-upstream-main"
publication_request_ref = "publication"
[antecedents]
publication_receipt_required = true
github_publication_required = true
maintainer_review_required = true
credit_ledger_required = true
public_proof_required = true
[required_receipts]
bifrost_publication = "gamecult.bifrost.public_proof_publication_receipt.v0"
github_publication = "gamecult.github.publication_receipt.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
credit_ledger = "gamecult.bifrost.credit_receipt.v0"
upstream_sync = "epiphany.repo_work_upstream_main_sync.v0"
ancestry_proof = "git.merge_base_is_ancestor"
[sync_proof]
target_ref = "origin/main"
requires_fetch_before_check = true
requires_merge_base_ancestor_check = true
requires_clean_public_proof_readback = true
records_upstream_main_sha = true
[authority]
branch_local_only = true
merge_authorized = false
# push_authorized = false
push_authorized = true
upstream_sync_authorized = false
github_publication_authorized = false
credit_ledger_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
bifrost_upstream_proof_required = true
maintainer_review_receipt_required = true
"#;
let request = parse_repo_sync_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn pr_comment_cannot_counterfeit_github_seal() {
let text = r#"
schema_version = "epiphany.repo_pr_request.v0"
safe_action_family = "repo.pr_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-pr-publication-review"
routing_owner = "Self"
publication_owner = "Bifrost"
execution_owner = "Hands"
provider = "GitHub"
provider_receipt_required = true
requested_effect = "open-or-update-review-pr-from-redacted-proof-and-maintainer-context"
maintainer_review_request_ref = "review"
publication_request_ref = "publication"
sync_request_ref = "sync"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_required = true
maintainer_review_required = true
bifrost_publication_required = true
credit_ledger_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
bifrost_publication = "gamecult.bifrost.public_proof_publication_receipt.v0"
credit_ledger = "gamecult.bifrost.credit_receipt.v0"
pr_publication = "gamecult.github.pull_request_publication_receipt.v0"
[pr_packet]
base_ref = "origin/main"
requires_branch_name = true
requires_title = true
requires_body = true
requires_changed_path_list = true
requires_public_proof_ref = true
requires_maintainer_review_ref = true
requires_credit_ref = true
requires_private_state_redaction_check = true
[authority]
branch_local_only = true
# github_pr_authorized = false
github_pr_authorized = true
branch_push_authorized = false
merge_authorized = false
publication_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
maintainer_review_required = true
bifrost_publication_gate_required = true
hands_execution_required = true
github_provider_receipt_required = true
"#;
let request = parse_repo_pr_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn maintainer_comment_cannot_counterfeit_approval_seal() {
let text = r#"
schema_version = "epiphany.repo_maintainer_review_request.v0"
safe_action_family = "repo.maintainer_review_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-maintainer-review"
requested_owner = "Maintainer"
requested_effect = "review-redacted-proof-and-branch-diff"
verification_request_ref = "verification"
publication_request_ref = "publication"
[antecedents]
closure_review_required = true
soul_verdict_required = true
mind_commit_required = true
public_proof_required = true
bifrost_publication_request_required = true
[required_receipts]
closure_review = "epiphany.repo_work_closure_review.v0"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
public_proof = "epiphany.repo_work_public_proof_bundle.v0"
maintainer_review = "gamecult.maintainer.review_receipt.v0"
bifrost_publication = "gamecult.bifrost.public_proof_publication_receipt.v0"
[review_packet]
requires_reviewer_identity = true
requires_review_verdict = true
allowed_verdicts = ["approved", "changes-requested", "rejected", "needs-human-context"]
requires_changed_path_list = true
requires_public_proof_ref = true
requires_private_state_redaction_check = true
[authority]
branch_local_only = true
# maintainer_approval_authorized = false
maintainer_approval_authorized = true
merge_authorized = false
push_authorized = false
publication_authorized = false
upstream_sync_authorized = false
hands_action_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
maintainer_response_required = true
"#;
let request = parse_repo_maintainer_review_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
}

View file

@ -1,686 +0,0 @@
#[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_plan_adoption_review.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<RepoDeploymentConfig> {
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) routing_owner: String,
pub(super) required_reviewers: Vec<String>,
pub(super) policy_admission_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_security_review_required: bool,
pub(super) soul_security_verification_required: bool,
pub(super) mind_policy_admission_required: bool,
pub(super) bifrost_publication_review_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.routing_owner == "Self"
&& request.required_reviewers == ["Maintainer", "Soul", "Mind", "Bifrost"]
&& request.policy_admission_owner == "Mind"
&& 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_plan_adoption_review.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_security_review_required
&& authority.soul_security_verification_required
&& authority.mind_policy_admission_required
&& authority.bifrost_publication_review_required
}
}
pub(super) fn parse_repo_secret_policy_request(text: &str) -> Result<RepoSecretPolicyRequest> {
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) routing_owner: String,
pub(super) required_reviewers: Vec<String>,
pub(super) policy_admission_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_dependency_review_required: bool,
pub(super) soul_dependency_verification_required: bool,
pub(super) mind_policy_admission_required: bool,
pub(super) bifrost_publication_review_required: bool,
pub(super) supply_chain_audit_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.routing_owner == "Self"
&& request.required_reviewers == ["Maintainer", "Soul", "Mind", "Bifrost"]
&& request.policy_admission_owner == "Mind"
&& 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_plan_adoption_review.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_dependency_review_required
&& value.soul_dependency_verification_required
&& value.mind_policy_admission_required
&& value.bifrost_publication_review_required
&& value.supply_chain_audit_required
}
}
pub(super) fn parse_repo_dependency_policy_request(
text: &str,
) -> Result<RepoDependencyPolicyRequest> {
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) routing_owner: String,
pub(super) required_reviewers: Vec<String>,
pub(super) execution_owner: String,
pub(super) requested_effect: String,
pub(super) deployment_trigger: 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_watched_ref: bool,
pub(super) requires_source_commit_sha: bool,
pub(super) requires_deployment_script_ref: bool,
pub(super) requires_script_hash: bool,
pub(super) requires_script_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.routing_owner == "Self"
&& value.required_reviewers == ["Maintainer", "Soul", "Mind", "Bifrost"]
&& value.execution_owner == "Idunn"
&& value.requested_effect == "review-repo-deployment-trigger-and-script"
&& value.deployment_trigger == "git-push-observed-by-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_plan_adoption_review.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_watched_ref
&& value.requires_source_commit_sha
&& value.requires_deployment_script_ref
&& value.requires_script_hash
&& value.requires_script_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<RepoDeploymentRequest> {
toml::from_str(text).context("deployment request is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoDoctrineUpdateRequest {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
request: RepoDoctrineRequestBody,
antecedents: std::collections::BTreeMap<String, bool>,
required_receipts: std::collections::BTreeMap<String, String>,
doctrine_packet: std::collections::BTreeMap<String, bool>,
authority: std::collections::BTreeMap<String, bool>,
}
impl RepoDoctrineUpdateRequest {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_doctrine_update_request.v0"
&& self.safe_action_family == "repo.doctrine_update_request"
}
pub(super) fn has_coherent_routing(&self) -> bool {
let r = &self.request;
r.status == "awaiting-doctrine-review"
&& r.routing_owner == "Self"
&& r.required_reviewers == ["Maintainer", "Mind", "Soul"]
&& r.doctrine_admission_owner == "Mind"
&& r.mutation_owner == "Hands"
&& r.requested_effect == "review-repo-agent-doctrine-update"
&& r.doctrine_target == "AGENTS.md"
&& r.requires_source_grounding
&& r.maintainer_review_required
}
pub(super) fn has_antecedent_contract(&self) -> bool {
[
"persona_or_human_feedback_required",
"imagination_plan_required",
"mind_adoption_required",
"soul_review_required",
"maintainer_review_required",
]
.iter()
.all(|key| self.antecedents.get(*key) == Some(&true))
}
pub(super) fn has_receipt_contract(&self) -> bool {
[
(
"imagination_plan",
"epiphany.repo_work_imagination_action_items_receipt.v0",
),
(
"mind_adoption",
"epiphany.repo_work_plan_adoption_review.v0",
),
("soul_review", "epiphany.repo_work_closure_review.v0"),
("maintainer_review", "gamecult.maintainer.review_receipt.v0"),
("hands_commit", "epiphany.hands.commit_receipt"),
]
.iter()
.all(|(key, value)| self.required_receipts.get(*key).is_some_and(|v| v == value))
}
pub(super) fn has_packet_contract(&self) -> bool {
[
"requires_current_doctrine_ref",
"requires_proposed_change_summary",
"requires_invariant_impact",
"requires_rehydration_impact",
"requires_rollback_plan",
"requires_private_state_redaction_check",
]
.iter()
.all(|key| self.doctrine_packet.get(*key) == Some(&true))
}
pub(super) fn has_authority_seals(&self) -> bool {
[
"direct_doctrine_mutation_authority",
"direct_hands_authority",
"direct_mind_state_commit",
"publication_authorized",
"merge_authorized",
"service_lifecycle_authority",
"cross_body_mutation_authorized",
"private_verse_rummaging",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&false))
&& [
"maintainer_review_required",
"mind_admission_required",
"hands_receipts_required",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&true))
}
}
#[derive(Debug, Deserialize)]
struct RepoDoctrineRequestBody {
status: String,
routing_owner: String,
required_reviewers: Vec<String>,
doctrine_admission_owner: String,
mutation_owner: String,
requested_effect: String,
doctrine_target: String,
requires_source_grounding: bool,
maintainer_review_required: bool,
}
pub(super) fn parse_repo_doctrine_update_request(text: &str) -> Result<RepoDoctrineUpdateRequest> {
toml::from_str(text).context("doctrine update request is not valid typed TOML")
}

View file

@ -1,311 +0,0 @@
#[derive(Debug, Deserialize)]
pub(super) struct RepoConsensusBrief {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
consensus: RepoConsensusState,
imagination: RepoConsensusImagination,
inputs: RepoConsensusInputs,
authority: std::collections::BTreeMap<String, bool>,
}
impl RepoConsensusBrief {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_consensus_brief.v0"
&& self.safe_action_family == "repo.consensus_brief"
}
pub(super) fn remains_unconverged_draft(&self) -> bool {
self.consensus.status == "draft"
&& !self.consensus.converged
&& self.consensus.conflicts_remaining
&& self.consensus.requires_additional_public_feedback
}
pub(super) fn has_imagination_route(&self) -> bool {
let i = &self.imagination;
i.role == "consensus-discovery"
&& i.candidate_actions_non_authoritative
&& i.may_emit_action_items_receipt
&& i.must_preserve_public_refs
&& i.must_not_read_private_verses
}
pub(super) fn has_input_contract(&self) -> bool {
self.inputs.feedback_source == "Persona public discussion"
&& self
.inputs
.public_discussion_refs
.iter()
.all(|v| !v.trim().is_empty())
&& self
.inputs
.candidate_action_refs
.iter()
.all(|v| !v.trim().is_empty())
}
pub(super) fn has_authority_seals(&self) -> bool {
[
"objective_adoption_authorized",
"hands_action_authorized",
"publication_authorized",
"cross_body_mutation_authorized",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&false))
&& self.authority.get("mind_adoption_required") == Some(&true)
&& self.authority.get("bifrost_publication_required") == Some(&true)
}
}
#[derive(Debug, Deserialize)]
struct RepoConsensusState {
status: String,
converged: bool,
conflicts_remaining: bool,
requires_additional_public_feedback: bool,
}
#[derive(Debug, Deserialize)]
struct RepoConsensusImagination {
role: String,
candidate_actions_non_authoritative: bool,
may_emit_action_items_receipt: bool,
must_preserve_public_refs: bool,
must_not_read_private_verses: bool,
}
#[derive(Debug, Deserialize)]
struct RepoConsensusInputs {
public_discussion_refs: Vec<String>,
candidate_action_refs: Vec<String>,
feedback_source: String,
}
pub(super) fn parse_repo_consensus_brief(text: &str) -> Result<RepoConsensusBrief> {
toml::from_str(text).context("consensus brief is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoInterpreterBrief {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
interpreter: RepoInterpreterRequest,
semantic_checks: std::collections::BTreeMap<String, bool>,
allowed_outputs: RepoInterpreterOutputs,
required_gates: std::collections::BTreeMap<String, bool>,
authority: std::collections::BTreeMap<String, bool>,
}
impl RepoInterpreterBrief {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_interpreter_brief.v0"
&& self.safe_action_family == "repo.interpreter_brief"
}
pub(super) fn is_imagination_request_for_mind(&self) -> bool {
let i = &self.interpreter;
i.status == "awaiting-mind-interpretation"
&& i.authoring_owner == "Imagination"
&& i.requested_interpreter == "Mind"
&& !i.interpretation_admitted
&& i.purpose == "public-pressure-to-action-semantics"
&& i.requires_consensus_readback
&& i.requires_safe_family_choice
&& i.requires_requested_paths
&& i.requires_verification_asks
&& i.requires_evidence_needs
&& i.candidate_actions_non_authoritative
}
pub(super) fn has_semantic_checks(&self) -> bool {
[
"intent_summary_required",
"scope_boundary_required",
"requested_paths_required",
"verification_required",
"evidence_required",
"rollback_required",
"non_goals_required",
"open_questions_required",
"consensus_alignment_required",
]
.iter()
.all(|key| self.semantic_checks.get(*key) == Some(&true))
}
pub(super) fn has_allowed_outputs(&self) -> bool {
let o = &self.allowed_outputs;
o.candidate_safe_families
== [
"repo.consensus_brief",
"repo.objective_draft",
"repo.adoption_request",
"repo.work_order",
"repo.verification_request",
"repo.publication_request",
]
&& o.may_request_replanning
&& o.may_request_more_consensus
&& !o.may_adopt_objective
&& !o.may_schedule_work
&& !o.may_touch_substrate
&& !o.may_publish
&& !o.may_deploy
}
pub(super) fn has_required_gates(&self) -> bool {
[
"imagination_consensus_required",
"mind_review_required",
"soul_source_grounding_required",
"bifrost_publication_review_required",
"hands_receipt_required_before_state_change",
"substrate_receipt_required_before_mutation",
"idunn_receipt_required_before_deployment",
]
.iter()
.all(|key| self.required_gates.get(*key) == Some(&true))
}
pub(super) fn has_authority_seals(&self) -> bool {
[
"direct_state_commit_authorized",
"objective_adoption_authorized",
"self_scheduling_authorized",
"substrate_access_authorized",
"hands_action_authorized",
"shell_command_authorized",
"commit_authorized",
"publication_authorized",
"deployment_execution_authority",
"cross_body_mutation_authorized",
"private_worker_transcripts_allowed",
"raw_result_payloads_allowed",
"private_state_exposed",
]
.iter()
.all(|key| self.authority.get(*key) == Some(&false))
}
}
#[derive(Debug, Deserialize)]
struct RepoInterpreterRequest {
status: String,
authoring_owner: String,
requested_interpreter: String,
interpretation_admitted: bool,
purpose: String,
requires_consensus_readback: bool,
requires_safe_family_choice: bool,
requires_requested_paths: bool,
requires_verification_asks: bool,
requires_evidence_needs: bool,
candidate_actions_non_authoritative: bool,
}
#[derive(Debug, Deserialize)]
struct RepoInterpreterOutputs {
candidate_safe_families: Vec<String>,
may_request_replanning: bool,
may_request_more_consensus: bool,
may_adopt_objective: bool,
may_schedule_work: bool,
may_touch_substrate: bool,
may_publish: bool,
may_deploy: bool,
}
pub(super) fn parse_repo_interpreter_brief(text: &str) -> Result<RepoInterpreterBrief> {
toml::from_str(text).context("interpreter brief is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoObjectiveDraft {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
draft: RepoObjectiveDraftState,
acceptance: RepoObjectiveDraftAcceptance,
inputs: RepoObjectiveDraftInputs,
authority: RepoObjectiveDraftAuthority,
}
impl RepoObjectiveDraft {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_objective_draft.v0"
&& self.safe_action_family == "repo.objective_draft"
}
pub(super) fn remains_imagination_draft(&self) -> bool {
let d = &self.draft;
d.status == "review-required"
&& d.owner == "Imagination"
&& d.adoption_gate == "Mind"
&& d.scheduler_gate == "Self"
&& d.publication_gate == "Bifrost"
&& !d.objective_adopted
}
pub(super) fn has_acceptance_contract(&self) -> bool {
self.acceptance.criteria
== [
"Mind explicitly accepts or rejects this Objective Draft before Self schedules it.",
"Self schedules only after Mind adoption and a safe-family action plan exist.",
"Hands acts only through a later receipt-backed plan and declared path scope.",
"Bifrost gates publication, credit, and upstream-main sync.",
]
}
pub(super) fn has_input_contract(&self) -> bool {
self.inputs.consensus_brief_required
&& self
.inputs
.public_discussion_refs
.iter()
.all(|v| !v.trim().is_empty())
&& self
.inputs
.candidate_action_refs
.iter()
.all(|v| !v.trim().is_empty())
}
pub(super) fn has_authority_seals(&self) -> bool {
let a = &self.authority;
a.branch_local_only
&& !a.objective_adoption_authorized
&& !a.self_scheduling_authorized
&& !a.hands_action_authorized
&& !a.publication_authorized
&& !a.cross_body_mutation_authorized
&& a.mind_adoption_required
&& a.bifrost_publication_required
}
}
#[derive(Debug, Deserialize)]
struct RepoObjectiveDraftState {
status: String,
owner: String,
adoption_gate: String,
scheduler_gate: String,
publication_gate: String,
objective_adopted: bool,
}
#[derive(Debug, Deserialize)]
struct RepoObjectiveDraftAcceptance {
criteria: Vec<String>,
}
#[derive(Debug, Deserialize)]
struct RepoObjectiveDraftInputs {
public_discussion_refs: Vec<String>,
candidate_action_refs: Vec<String>,
consensus_brief_required: bool,
}
#[derive(Debug, Deserialize)]
struct RepoObjectiveDraftAuthority {
branch_local_only: bool,
objective_adoption_authorized: bool,
self_scheduling_authorized: bool,
hands_action_authorized: bool,
publication_authorized: bool,
cross_body_mutation_authorized: bool,
mind_adoption_required: bool,
bifrost_publication_required: bool,
}
pub(super) fn parse_repo_objective_draft(text: &str) -> Result<RepoObjectiveDraft> {
toml::from_str(text).context("objective draft is not valid typed TOML")
}
include!("preparation_tests.rs");

View file

@ -1,112 +0,0 @@
#[cfg(test)]
mod preparation_tests {
use super::*;
#[test]
fn consensus_comment_cannot_counterfeit_adoption_seal() {
let text = r#"
schema_version = "epiphany.repo_consensus_brief.v0"
safe_action_family = "repo.consensus_brief"
summary = "summary"
private_state_exposed = false
[consensus]
status = "draft"
converged = false
conflicts_remaining = true
requires_additional_public_feedback = true
[imagination]
role = "consensus-discovery"
candidate_actions_non_authoritative = true
may_emit_action_items_receipt = true
must_preserve_public_refs = true
must_not_read_private_verses = true
[inputs]
public_discussion_refs = []
candidate_action_refs = []
feedback_source = "Persona public discussion"
[authority]
# objective_adoption_authorized = false
objective_adoption_authorized = true
hands_action_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
mind_adoption_required = true
bifrost_publication_required = true
"#;
let brief = parse_repo_consensus_brief(text).expect("fixture is typed TOML");
assert!(!brief.has_authority_seals());
}
#[test]
fn interpreter_comment_cannot_counterfeit_state_authority_seal() {
let text = r#"
schema_version = "epiphany.repo_interpreter_brief.v0"
safe_action_family = "repo.interpreter_brief"
summary = "summary"
private_state_exposed = false
[interpreter]
status = "awaiting-mind-interpretation"
authoring_owner = "Imagination"
requested_interpreter = "Mind"
interpretation_admitted = false
purpose = "public-pressure-to-action-semantics"
requires_consensus_readback = true
requires_safe_family_choice = true
requires_requested_paths = true
requires_verification_asks = true
requires_evidence_needs = true
candidate_actions_non_authoritative = true
[semantic_checks]
[allowed_outputs]
candidate_safe_families = []
may_request_replanning = false
may_request_more_consensus = false
may_adopt_objective = false
may_schedule_work = false
may_touch_substrate = false
may_publish = false
may_deploy = false
[required_gates]
[authority]
# direct_state_commit_authorized = false
direct_state_commit_authorized = true
"#;
let brief = parse_repo_interpreter_brief(text).expect("fixture is typed TOML");
assert!(!brief.has_authority_seals());
}
#[test]
fn objective_draft_comment_cannot_counterfeit_adoption_seal() {
let text = r#"
schema_version = "epiphany.repo_objective_draft.v0"
safe_action_family = "repo.objective_draft"
summary = "summary"
private_state_exposed = false
[draft]
status = "review-required"
owner = "Imagination"
adoption_gate = "Mind"
scheduler_gate = "Self"
publication_gate = "Bifrost"
objective_adopted = false
[acceptance]
criteria = ["Mind explicitly accepts or rejects this Objective Draft before Self schedules it.", "Self schedules only after Mind adoption and a safe-family action plan exist.", "Hands acts only through a later receipt-backed plan and declared path scope.", "Bifrost gates publication, credit, and upstream-main sync."]
[inputs]
public_discussion_refs = []
candidate_action_refs = []
consensus_brief_required = true
[authority]
branch_local_only = true
# objective_adoption_authorized = false
objective_adoption_authorized = true
self_scheduling_authorized = false
hands_action_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
mind_adoption_required = true
bifrost_publication_required = true
"#;
let draft = parse_repo_objective_draft(text).expect("fixture is typed TOML");
assert!(!draft.has_authority_seals());
}
}

View file

@ -1,431 +0,0 @@
#[derive(Debug, Deserialize)]
pub(super) struct RepoWorkOrder {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
work_order: RepoWorkOrderBody,
antecedents: RepoWorkOrderAntecedents,
required_receipts: RepoWorkOrderReceipts,
scope: RepoWorkOrderScope,
authority: RepoWorkOrderAuthority,
}
impl RepoWorkOrder {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_work_order.v0"
&& self.safe_action_family == "repo.work_order"
}
pub(super) fn awaits_hands_review(&self) -> bool {
self.work_order.status == "awaiting-hands-review"
&& self.work_order.requested_owner == "Hands"
&& self.work_order.requested_effect == "branch-local-implementation"
}
pub(super) fn has_antecedent_contract(&self) -> bool {
!self.antecedents.objective_draft_ref.is_empty()
&& !self.antecedents.adoption_request_ref.is_empty()
&& !self.antecedents.scheduling_request_ref.is_empty()
&& self.antecedents.mind_adoption_required
&& self.antecedents.self_queue_selection_required
}
pub(super) fn has_receipt_contract(&self) -> bool {
let r = &self.required_receipts;
r.substrate_gate == "epiphany.substrate_gate.grant"
&& r.hands_intent == "epiphany.hands.action_intent"
&& r.hands_review == "epiphany.hands.action_review"
&& r.hands_patch == "epiphany.hands.patch_receipt"
&& r.hands_command == "epiphany.hands.command_receipt"
&& r.hands_commit == "epiphany.hands.commit_receipt"
&& r.soul_verdict == "epiphany.soul.verification_verdict"
&& r.mind_commit == "epiphany.mind.state_commit_receipt"
}
pub(super) fn has_bounded_scope(&self) -> bool {
self.scope.branch_required
&& self.scope.allowed_branch_prefix == "epiphany/"
&& self.scope.max_changed_paths == 3
&& self.scope.requires_reviewable_diff
}
pub(super) fn has_authority_seals(&self) -> bool {
let a = &self.authority;
a.branch_local_only
&& !a.substrate_access_authorized
&& !a.hands_action_authorized
&& !a.shell_command_authorized
&& !a.commit_authorized
&& !a.publication_authorized
&& !a.cross_body_mutation_authorized
&& a.bifrost_publication_required
}
}
#[derive(Debug, Deserialize)]
struct RepoWorkOrderBody {
status: String,
requested_owner: String,
requested_effect: String,
}
#[derive(Debug, Deserialize)]
struct RepoWorkOrderAntecedents {
objective_draft_ref: String,
adoption_request_ref: String,
scheduling_request_ref: String,
mind_adoption_required: bool,
self_queue_selection_required: bool,
}
#[derive(Debug, Deserialize)]
struct RepoWorkOrderReceipts {
substrate_gate: String,
hands_intent: String,
hands_review: String,
hands_patch: String,
hands_command: String,
hands_commit: String,
soul_verdict: String,
mind_commit: String,
}
#[derive(Debug, Deserialize)]
struct RepoWorkOrderScope {
branch_required: bool,
allowed_branch_prefix: String,
max_changed_paths: u64,
requires_reviewable_diff: bool,
}
#[derive(Debug, Deserialize)]
struct RepoWorkOrderAuthority {
branch_local_only: bool,
substrate_access_authorized: bool,
hands_action_authorized: bool,
shell_command_authorized: bool,
commit_authorized: bool,
publication_authorized: bool,
cross_body_mutation_authorized: bool,
bifrost_publication_required: bool,
}
pub(super) fn parse_repo_work_order(text: &str) -> Result<RepoWorkOrder> {
toml::from_str(text).context("work order is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoSchedulingRequest {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
request: RepoSchedulingBody,
queue: RepoSchedulingQueue,
required_receipts: RepoSchedulingReceipts,
authority: RepoSchedulingAuthority,
}
impl RepoSchedulingRequest {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_scheduling_request.v0"
&& self.safe_action_family == "repo.scheduling_request"
}
pub(super) fn awaits_mind_adoption(&self) -> bool {
let r = &self.request;
r.status == "awaiting-mind-adoption"
&& r.requested_scheduler == "Self"
&& r.mind_adoption_receipt_required
&& r.self_may_schedule_after_mind_only
&& r.queue_run_allowed_after_adoption
}
pub(super) fn has_bounded_queue_contract(&self) -> bool {
let q = &self.queue;
q.target_gate == "repo-work-queue"
&& q.preferred_next_safe_family == "repo.task_card"
&& q.max_items_per_pulse == 1
&& q.requires_epiphany_branch
&& q.publish_blocker == "bifrost-publication-missing"
}
pub(super) fn has_receipt_contract(&self) -> bool {
let r = &self.required_receipts;
r.mind_review == "epiphany.mind.gateway_review"
&& r.mind_commit == "epiphany.mind.state_commit_receipt"
&& r.expected_self_receipt == "epiphany.repo_work_queue_selection.v0"
}
pub(super) fn has_authority_seals(&self) -> bool {
let a = &self.authority;
a.branch_local_only
&& !a.self_scheduling_authorized
&& !a.queue_mutation_authorized
&& !a.hands_action_authorized
&& !a.publication_authorized
&& !a.cross_body_mutation_authorized
&& a.mind_adoption_required
&& a.bifrost_publication_required
}
}
#[derive(Debug, Deserialize)]
struct RepoSchedulingBody {
status: String,
requested_scheduler: String,
mind_adoption_receipt_required: bool,
self_may_schedule_after_mind_only: bool,
queue_run_allowed_after_adoption: bool,
}
#[derive(Debug, Deserialize)]
struct RepoSchedulingQueue {
target_gate: String,
preferred_next_safe_family: String,
max_items_per_pulse: u64,
requires_epiphany_branch: bool,
publish_blocker: String,
}
#[derive(Debug, Deserialize)]
struct RepoSchedulingReceipts {
mind_review: String,
mind_commit: String,
expected_self_receipt: String,
}
#[derive(Debug, Deserialize)]
struct RepoSchedulingAuthority {
branch_local_only: bool,
self_scheduling_authorized: bool,
queue_mutation_authorized: bool,
hands_action_authorized: bool,
publication_authorized: bool,
cross_body_mutation_authorized: bool,
mind_adoption_required: bool,
bifrost_publication_required: bool,
}
pub(super) fn parse_repo_scheduling_request(text: &str) -> Result<RepoSchedulingRequest> {
toml::from_str(text).context("scheduling request is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoAdoptionRequest {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
request: RepoAdoptionBody,
decision_contract: RepoAdoptionDecisionContract,
inputs: RepoAdoptionInputs,
authority: RepoAdoptionAuthority,
}
impl RepoAdoptionRequest {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_adoption_request.v0"
&& self.safe_action_family == "repo.adoption_request"
}
pub(super) fn awaits_mind_review(&self) -> bool {
let r = &self.request;
r.status == "awaiting-mind-review"
&& r.requested_decision == "adopt-or-refuse-objective-draft"
&& r.mind_review_required
&& r.mind_state_commit_required
&& r.self_scheduling_after_mind_only
}
pub(super) fn has_decision_contract(&self) -> bool {
let d = &self.decision_contract;
d.allowed_verdicts == ["adopted", "refused", "needs-more-consensus"]
&& d.requires_review_finding
&& d.requires_receipt == "epiphany.mind.gateway_review"
&& d.requires_commit_receipt_if_adopted == "epiphany.mind.state_commit_receipt"
&& d.does_not_modify_state
}
pub(super) fn has_input_contract(&self) -> bool {
self.inputs.objective_draft_required
&& self.inputs.consensus_brief_required
&& self
.inputs
.public_discussion_refs
.iter()
.all(|value| !value.trim().is_empty())
&& self
.inputs
.candidate_action_refs
.iter()
.all(|value| !value.trim().is_empty())
}
pub(super) fn has_authority_seals(&self) -> bool {
let a = &self.authority;
a.branch_local_only
&& !a.objective_adoption_authorized
&& !a.state_commit_authorized
&& !a.self_scheduling_authorized
&& !a.hands_action_authorized
&& !a.publication_authorized
&& !a.cross_body_mutation_authorized
}
}
#[derive(Debug, Deserialize)]
struct RepoAdoptionBody {
status: String,
requested_decision: String,
mind_review_required: bool,
mind_state_commit_required: bool,
self_scheduling_after_mind_only: bool,
}
#[derive(Debug, Deserialize)]
struct RepoAdoptionDecisionContract {
allowed_verdicts: Vec<String>,
requires_review_finding: bool,
requires_receipt: String,
requires_commit_receipt_if_adopted: String,
does_not_modify_state: bool,
}
#[derive(Debug, Deserialize)]
struct RepoAdoptionInputs {
public_discussion_refs: Vec<String>,
candidate_action_refs: Vec<String>,
objective_draft_required: bool,
consensus_brief_required: bool,
}
#[derive(Debug, Deserialize)]
struct RepoAdoptionAuthority {
branch_local_only: bool,
objective_adoption_authorized: bool,
state_commit_authorized: bool,
self_scheduling_authorized: bool,
hands_action_authorized: bool,
publication_authorized: bool,
cross_body_mutation_authorized: bool,
}
pub(super) fn parse_repo_adoption_request(text: &str) -> Result<RepoAdoptionRequest> {
toml::from_str(text).context("adoption request is not valid typed TOML")
}
#[derive(Debug, Deserialize)]
pub(super) struct RepoVerificationRequest {
pub(super) schema_version: String,
pub(super) safe_action_family: String,
pub(super) summary: String,
pub(super) private_state_exposed: bool,
request: RepoVerificationBody,
antecedents: RepoVerificationAntecedents,
required_receipts: RepoVerificationReceipts,
checks: RepoVerificationChecks,
authority: RepoVerificationAuthority,
}
impl RepoVerificationRequest {
pub(super) fn has_canonical_identity(&self) -> bool {
self.schema_version == "epiphany.repo_verification_request.v0"
&& self.safe_action_family == "repo.verification_request"
}
pub(super) fn awaits_soul_review(&self) -> bool {
let r = &self.request;
r.status == "awaiting-soul-review"
&& r.requested_owner == "Soul"
&& r.requested_effect == "verify-branch-local-hands-work"
&& !r.work_order_ref.is_empty()
}
pub(super) fn has_antecedent_contract(&self) -> bool {
let a = &self.antecedents;
a.substrate_gate_required
&& a.hands_intent_required
&& a.hands_review_required
&& a.hands_patch_required
&& a.hands_command_required
&& a.hands_commit_required
&& a.work_order_required
}
pub(super) fn has_receipt_contract(&self) -> bool {
let r = &self.required_receipts;
r.hands_patch == "epiphany.hands.patch_receipt"
&& r.hands_command == "epiphany.hands.command_receipt"
&& r.hands_commit == "epiphany.hands.commit_receipt"
&& r.soul_verdict == "epiphany.soul.verification_verdict"
&& r.closure_review == "epiphany.repo_work_closure_review.v0"
&& r.mind_review == "epiphany.mind.gateway_review"
&& r.mind_commit == "epiphany.mind.state_commit_receipt"
}
pub(super) fn has_check_contract(&self) -> bool {
self.checks.required
== [
"declared-paths-match-commit",
"hands-receipts-present",
"visible-diff-supports-summary",
"no-private-state-exposure",
"publication-remains-gated",
]
&& self.checks.model_verdict_allowed
&& self.checks.failure_blocks_mind_admission
}
pub(super) fn has_authority_seals(&self) -> bool {
let a = &self.authority;
a.branch_local_only
&& !a.soul_verdict_authorized
&& !a.state_commit_authorized
&& !a.hands_action_authorized
&& !a.rerun_authorized
&& !a.publication_authorized
&& !a.merge_authorized
&& !a.service_lifecycle_authority
&& !a.cross_body_mutation_authorized
&& !a.private_verse_rummaging
&& a.bifrost_publication_required
}
}
#[derive(Debug, Deserialize)]
struct RepoVerificationBody {
status: String,
requested_owner: String,
requested_effect: String,
work_order_ref: String,
}
#[derive(Debug, Deserialize)]
struct RepoVerificationAntecedents {
substrate_gate_required: bool,
hands_intent_required: bool,
hands_review_required: bool,
hands_patch_required: bool,
hands_command_required: bool,
hands_commit_required: bool,
work_order_required: bool,
}
#[derive(Debug, Deserialize)]
struct RepoVerificationReceipts {
hands_patch: String,
hands_command: String,
hands_commit: String,
soul_verdict: String,
closure_review: String,
mind_review: String,
mind_commit: String,
}
#[derive(Debug, Deserialize)]
struct RepoVerificationChecks {
required: Vec<String>,
model_verdict_allowed: bool,
failure_blocks_mind_admission: bool,
}
#[derive(Debug, Deserialize)]
struct RepoVerificationAuthority {
branch_local_only: bool,
soul_verdict_authorized: bool,
state_commit_authorized: bool,
hands_action_authorized: bool,
rerun_authorized: bool,
publication_authorized: bool,
merge_authorized: bool,
service_lifecycle_authority: bool,
cross_body_mutation_authorized: bool,
private_verse_rummaging: bool,
bifrost_publication_required: bool,
}
pub(super) fn parse_repo_verification_request(text: &str) -> Result<RepoVerificationRequest> {
toml::from_str(text).context("verification request is not valid typed TOML")
}
include!("workflow_tests.rs");

View file

@ -1,176 +0,0 @@
#[cfg(test)]
mod workflow_tests {
use super::*;
#[test]
fn adoption_comment_cannot_counterfeit_state_authority_seal() {
let text = r#"
schema_version = "epiphany.repo_adoption_request.v0"
safe_action_family = "repo.adoption_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-mind-review"
requested_decision = "adopt-or-refuse-objective-draft"
mind_review_required = true
mind_state_commit_required = true
self_scheduling_after_mind_only = true
[decision_contract]
allowed_verdicts = ["adopted", "refused", "needs-more-consensus"]
requires_review_finding = true
requires_receipt = "epiphany.mind.gateway_review"
requires_commit_receipt_if_adopted = "epiphany.mind.state_commit_receipt"
does_not_modify_state = true
[inputs]
public_discussion_refs = []
candidate_action_refs = []
objective_draft_required = true
consensus_brief_required = true
[authority]
branch_local_only = true
objective_adoption_authorized = false
# state_commit_authorized = false
state_commit_authorized = true
self_scheduling_authorized = false
hands_action_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
"#;
let request = parse_repo_adoption_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn scheduling_comment_cannot_counterfeit_queue_authority_seal() {
let text = r#"
schema_version = "epiphany.repo_scheduling_request.v0"
safe_action_family = "repo.scheduling_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-mind-adoption"
requested_scheduler = "Self"
mind_adoption_receipt_required = true
self_may_schedule_after_mind_only = true
queue_run_allowed_after_adoption = true
[queue]
target_gate = "repo-work-queue"
preferred_next_safe_family = "repo.task_card"
max_items_per_pulse = 1
requires_epiphany_branch = true
publish_blocker = "bifrost-publication-missing"
[required_receipts]
mind_review = "epiphany.mind.gateway_review"
mind_commit = "epiphany.mind.state_commit_receipt"
expected_self_receipt = "epiphany.repo_work_queue_selection.v0"
[authority]
branch_local_only = true
self_scheduling_authorized = false
# queue_mutation_authorized = false
queue_mutation_authorized = true
hands_action_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
mind_adoption_required = true
bifrost_publication_required = true
"#;
let request = parse_repo_scheduling_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
#[test]
fn work_order_comment_cannot_counterfeit_hands_authority_seal() {
let text = r#"
schema_version = "epiphany.repo_work_order.v0"
safe_action_family = "repo.work_order"
summary = "summary"
private_state_exposed = false
[work_order]
status = "awaiting-hands-review"
requested_owner = "Hands"
requested_effect = "branch-local-implementation"
[antecedents]
objective_draft_ref = "objective"
adoption_request_ref = "adoption"
scheduling_request_ref = "schedule"
mind_adoption_required = true
self_queue_selection_required = true
[required_receipts]
substrate_gate = "epiphany.substrate_gate.grant"
hands_intent = "epiphany.hands.action_intent"
hands_review = "epiphany.hands.action_review"
hands_patch = "epiphany.hands.patch_receipt"
hands_command = "epiphany.hands.command_receipt"
hands_commit = "epiphany.hands.commit_receipt"
soul_verdict = "epiphany.soul.verification_verdict"
mind_commit = "epiphany.mind.state_commit_receipt"
[scope]
branch_required = true
allowed_branch_prefix = "epiphany/"
max_changed_paths = 3
requires_reviewable_diff = true
[authority]
branch_local_only = true
substrate_access_authorized = false
# hands_action_authorized = false
hands_action_authorized = true
shell_command_authorized = false
commit_authorized = false
publication_authorized = false
cross_body_mutation_authorized = false
bifrost_publication_required = true
"#;
let work_order = parse_repo_work_order(text).expect("fixture is typed TOML");
assert!(!work_order.has_authority_seals());
}
#[test]
fn verification_comment_cannot_counterfeit_soul_verdict_seal() {
let text = r#"
schema_version = "epiphany.repo_verification_request.v0"
safe_action_family = "repo.verification_request"
summary = "summary"
private_state_exposed = false
[request]
status = "awaiting-soul-review"
requested_owner = "Soul"
requested_effect = "verify-branch-local-hands-work"
work_order_ref = "work-order"
[antecedents]
substrate_gate_required = true
hands_intent_required = true
hands_review_required = true
hands_patch_required = true
hands_command_required = true
hands_commit_required = true
work_order_required = true
[required_receipts]
hands_patch = "epiphany.hands.patch_receipt"
hands_command = "epiphany.hands.command_receipt"
hands_commit = "epiphany.hands.commit_receipt"
soul_verdict = "epiphany.soul.verification_verdict"
closure_review = "epiphany.repo_work_closure_review.v0"
mind_review = "epiphany.mind.gateway_review"
mind_commit = "epiphany.mind.state_commit_receipt"
[checks]
required = ["declared-paths-match-commit", "hands-receipts-present", "visible-diff-supports-summary", "no-private-state-exposure", "publication-remains-gated"]
model_verdict_allowed = true
failure_blocks_mind_admission = true
[authority]
branch_local_only = true
# soul_verdict_authorized = false
soul_verdict_authorized = true
state_commit_authorized = false
hands_action_authorized = false
rerun_authorized = false
publication_authorized = false
merge_authorized = false
service_lifecycle_authority = false
cross_body_mutation_authorized = false
private_verse_rummaging = false
bifrost_publication_required = true
"#;
let request = parse_repo_verification_request(text).expect("fixture is typed TOML");
assert!(!request.has_authority_seals());
}
}

View file

@ -5572,25 +5572,6 @@ fn agent_state_soa_generation_key(
)
}
pub fn write_epiphany_cultmesh_repo_work_overview(
store_path: impl AsRef<Path>,
overview: EpiphanyCultMeshRepoWorkOverviewEntry,
) -> Result<EpiphanyCultMeshRepoWorkOverviewEntry> {
validate_repo_work_overview(&overview)?;
let mut node = open_epiphany_cultmesh_node(&store_path, overview.runtime_id.clone())?;
let written = node.put(overview.overview_id.clone(), &overview)?;
let current_latest = node.get::<EpiphanyCultMeshRepoWorkOverviewEntry>(
EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_LATEST_KEY,
)?;
if current_latest.as_ref().is_none_or(|current| {
repo_work_overview_generation_key(&written) >= repo_work_overview_generation_key(current)
}) {
node.put(EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_LATEST_KEY, &written)?;
}
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_repo_work_overview(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
@ -5618,25 +5599,6 @@ pub fn load_epiphany_cultmesh_repo_work_overviews(
Ok(overviews)
}
pub fn write_epiphany_cultmesh_repo_work_readiness(
store_path: impl AsRef<Path>,
readiness: EpiphanyCultMeshRepoWorkReadinessEntry,
) -> Result<EpiphanyCultMeshRepoWorkReadinessEntry> {
validate_repo_work_readiness(&readiness)?;
let mut node = open_epiphany_cultmesh_node(&store_path, readiness.runtime_id.clone())?;
let written = node.put(readiness.readiness_id.clone(), &readiness)?;
let current_latest = node.get::<EpiphanyCultMeshRepoWorkReadinessEntry>(
EPIPHANY_CULTMESH_REPO_WORK_READINESS_LATEST_KEY,
)?;
if current_latest.as_ref().is_none_or(|current| {
repo_work_readiness_generation_key(&written) >= repo_work_readiness_generation_key(current)
}) {
node.put(EPIPHANY_CULTMESH_REPO_WORK_READINESS_LATEST_KEY, &written)?;
}
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_repo_work_readiness(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
@ -5664,25 +5626,6 @@ pub fn load_epiphany_cultmesh_repo_work_readiness_reports(
Ok(reports)
}
pub fn write_epiphany_cultmesh_repo_work_map_entry(
store_path: impl AsRef<Path>,
map_entry: EpiphanyCultMeshRepoWorkMapEntry,
) -> Result<EpiphanyCultMeshRepoWorkMapEntry> {
validate_repo_work_map_entry(&map_entry)?;
let mut node = open_epiphany_cultmesh_node(&store_path, map_entry.runtime_id.clone())?;
let written = node.put(map_entry.map_entry_id.clone(), &map_entry)?;
let current_latest = node.get::<EpiphanyCultMeshRepoWorkMapEntry>(
EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY,
)?;
if current_latest.as_ref().is_none_or(|current| {
repo_work_map_admission_key(&written) >= repo_work_map_admission_key(current)
}) {
node.put(EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_LATEST_KEY, &written)?;
}
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_repo_work_map_entry(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
@ -5710,29 +5653,6 @@ pub fn load_epiphany_cultmesh_repo_work_map_entries(
Ok(entries)
}
pub fn write_epiphany_cultmesh_repo_work_public_proof(
store_path: impl AsRef<Path>,
proof: EpiphanyCultMeshRepoWorkPublicProofEntry,
) -> Result<EpiphanyCultMeshRepoWorkPublicProofEntry> {
validate_repo_work_public_proof(&proof)?;
let mut node = open_epiphany_cultmesh_node(&store_path, proof.runtime_id.clone())?;
let written = node.put(proof.public_proof_id.clone(), &proof)?;
let current_latest = node.get::<EpiphanyCultMeshRepoWorkPublicProofEntry>(
EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_LATEST_KEY,
)?;
if current_latest.as_ref().is_none_or(|current| {
repo_work_public_proof_generation_key(&written)
>= repo_work_public_proof_generation_key(current)
}) {
node.put(
EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_LATEST_KEY,
&written,
)?;
}
node.flush()?;
Ok(written)
}
pub fn load_latest_epiphany_cultmesh_repo_work_public_proof(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
@ -5760,228 +5680,6 @@ pub fn load_epiphany_cultmesh_repo_work_public_proofs(
Ok(proofs)
}
fn validate_repo_work_overview(overview: &EpiphanyCultMeshRepoWorkOverviewEntry) -> Result<()> {
if overview.private_state_exposed {
return Err(anyhow!("repo work overview must not expose private state"));
}
if overview.schema_version != EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_SCHEMA_VERSION {
return Err(anyhow!(
"repo work overview schema_version must be {:?}",
EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_SCHEMA_VERSION
));
}
if overview.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID {
return Err(anyhow!(
"repo work overview belongs in local-area Verse {:?}",
EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID
));
}
if overview.overview_id.trim().is_empty() || overview.item.trim().is_empty() {
return Err(anyhow!("repo work overview requires overview_id and item"));
}
DateTime::parse_from_rfc3339(&overview.generated_at)
.map_err(|error| anyhow!("repo work overview has invalid generated_at: {error}"))?;
if overview.tui_rows.is_empty() {
return Err(anyhow!("repo work overview requires compact TUI rows"));
}
if overview
.tui_rows
.iter()
.any(|row| row.to_ascii_lowercase().contains("rawresult"))
{
return Err(anyhow!(
"repo work overview rows must not expose raw worker payload names"
));
}
Ok(())
}
fn repo_work_overview_generation_key(
overview: &EpiphanyCultMeshRepoWorkOverviewEntry,
) -> (DateTime<FixedOffset>, &str) {
(
DateTime::parse_from_rfc3339(&overview.generated_at)
.expect("validated repo work overview generation timestamp"),
overview.overview_id.as_str(),
)
}
fn validate_repo_work_readiness(readiness: &EpiphanyCultMeshRepoWorkReadinessEntry) -> Result<()> {
if readiness.private_state_exposed {
return Err(anyhow!("repo work readiness must not expose private state"));
}
if readiness.schema_version != EPIPHANY_CULTMESH_REPO_WORK_READINESS_SCHEMA_VERSION {
return Err(anyhow!(
"repo work readiness schema_version must be {:?}",
EPIPHANY_CULTMESH_REPO_WORK_READINESS_SCHEMA_VERSION
));
}
if readiness.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID {
return Err(anyhow!(
"repo work readiness belongs in local-area Verse {:?}",
EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID
));
}
if readiness.readiness_id.trim().is_empty() || readiness.item.trim().is_empty() {
return Err(anyhow!(
"repo work readiness requires readiness_id and item"
));
}
DateTime::parse_from_rfc3339(&readiness.generated_at)
.map_err(|error| anyhow!("repo work readiness has invalid generated_at: {error}"))?;
if !readiness.sight_only
|| readiness.readiness_approval_authorized
|| readiness.publication_authorized
|| readiness.service_lifecycle_authority
|| readiness.hands_action_authorized
{
return Err(anyhow!(
"repo work readiness is sight only and must not grant approval, publication, service, or Hands authority"
));
}
if readiness.tui_rows.is_empty() {
return Err(anyhow!("repo work readiness requires compact TUI rows"));
}
if readiness.tui_rows.iter().any(|row| {
let lower = row.to_ascii_lowercase();
lower.contains("rawresult") || lower.contains("receipt body") || lower.contains("thought")
}) {
return Err(anyhow!(
"repo work readiness rows must not expose raw worker payload names"
));
}
Ok(())
}
fn repo_work_readiness_generation_key(
readiness: &EpiphanyCultMeshRepoWorkReadinessEntry,
) -> (DateTime<FixedOffset>, &str) {
(
DateTime::parse_from_rfc3339(&readiness.generated_at)
.expect("validated repo work readiness generation timestamp"),
readiness.readiness_id.as_str(),
)
}
fn validate_repo_work_map_entry(entry: &EpiphanyCultMeshRepoWorkMapEntry) -> Result<()> {
if entry.private_state_exposed {
return Err(anyhow!("repo work map entry must not expose private state"));
}
if entry.schema_version != EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_SCHEMA_VERSION {
return Err(anyhow!(
"repo work map entry schema_version must be {:?}",
EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_SCHEMA_VERSION
));
}
if entry.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID {
return Err(anyhow!(
"repo work map entry belongs in local-area Verse {:?}",
EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID
));
}
if entry.map_entry_id.trim().is_empty() || entry.item.trim().is_empty() {
return Err(anyhow!(
"repo work map entry requires map_entry_id and item"
));
}
if entry.modeling_finding_receipt_id.trim().is_empty() {
return Err(anyhow!(
"repo work map entry requires a Modeling finding receipt"
));
}
if !entry.durable_state_admitted {
return Err(anyhow!(
"repo work map entry projection requires admitted durable state"
));
}
let admitted_at = DateTime::parse_from_rfc3339(&entry.admitted_at)
.map_err(|error| anyhow!("repo work map entry has invalid admitted_at: {error}"))?;
let mirrored_at = DateTime::parse_from_rfc3339(&entry.mirrored_at)
.map_err(|error| anyhow!("repo work map entry has invalid mirrored_at: {error}"))?;
if mirrored_at < admitted_at {
return Err(anyhow!(
"repo work map entry was mirrored before Mind admission"
));
}
if entry.tui_rows.is_empty() {
return Err(anyhow!("repo work map entry requires compact TUI rows"));
}
if entry
.tui_rows
.iter()
.any(|row| row.to_ascii_lowercase().contains("rawresult"))
{
return Err(anyhow!(
"repo work map entry rows must not expose raw worker payload names"
));
}
Ok(())
}
fn repo_work_map_admission_key(
entry: &EpiphanyCultMeshRepoWorkMapEntry,
) -> (DateTime<FixedOffset>, &str) {
(
DateTime::parse_from_rfc3339(&entry.admitted_at)
.expect("validated repo work map admission timestamp"),
entry.map_entry_id.as_str(),
)
}
fn validate_repo_work_public_proof(proof: &EpiphanyCultMeshRepoWorkPublicProofEntry) -> Result<()> {
if proof.private_state_exposed {
return Err(anyhow!(
"repo work public proof must not expose private state"
));
}
if proof.schema_version != EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_SCHEMA_VERSION {
return Err(anyhow!(
"repo work public proof schema_version must be {:?}",
EPIPHANY_CULTMESH_REPO_WORK_PUBLIC_PROOF_SCHEMA_VERSION
));
}
if proof.verse_id != EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID {
return Err(anyhow!(
"repo work public proof belongs in local-area Verse {:?}",
EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID
));
}
if proof.public_proof_id.trim().is_empty() || proof.item.trim().is_empty() {
return Err(anyhow!(
"repo work public proof requires public_proof_id and item"
));
}
DateTime::parse_from_rfc3339(&proof.generated_at)
.map_err(|error| anyhow!("repo work public proof has invalid generated_at: {error}"))?;
if proof.public_proof_ref.trim().is_empty() || proof.public_proof_sha256.trim().is_empty() {
return Err(anyhow!(
"repo work public proof requires artifact ref and sha256"
));
}
if proof.tui_rows.is_empty() {
return Err(anyhow!("repo work public proof requires compact TUI rows"));
}
if proof.tui_rows.iter().any(|row| {
let lower = row.to_ascii_lowercase();
lower.contains("rawresult") || lower.contains("receipt body") || lower.contains("thought")
}) {
return Err(anyhow!(
"repo work public proof rows must not expose raw worker payload names"
));
}
Ok(())
}
fn repo_work_public_proof_generation_key(
proof: &EpiphanyCultMeshRepoWorkPublicProofEntry,
) -> (DateTime<FixedOffset>, &str) {
(
DateTime::parse_from_rfc3339(&proof.generated_at)
.expect("validated repo work public proof generation timestamp"),
proof.public_proof_id.as_str(),
)
}
pub fn seed_epiphany_local_verse_context(
store_path: impl AsRef<Path>,
runtime_id: impl Into<String>,
@ -7618,164 +7316,6 @@ mod tests {
Ok(())
}
#[test]
fn repo_work_map_latest_follows_mind_admission_not_mirror_arrival() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("repo-work-map-order.ccmp");
let older = EpiphanyCultMeshRepoWorkMapEntry {
schema_version: EPIPHANY_CULTMESH_REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(),
runtime_id: "repo-work-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
map_entry_id: "repo-work-map-older".to_string(),
admitted_at: "2026-07-13T01:00:00Z".to_string(),
mirrored_at: "2026-07-13T01:00:01Z".to_string(),
workspace: "E:/Projects/test".to_string(),
item: "test-item".to_string(),
branch: "main".to_string(),
changed_paths: vec!["src/lib.rs".to_string()],
commit_sha: "older".to_string(),
safe_action_family: "planning-note".to_string(),
modeling_summary: "Older admitted map.".to_string(),
soul_verdict_receipt_id: "soul-older".to_string(),
mind_gateway_review_id: "mind-review-older".to_string(),
mind_state_commit_receipt_id: "mind-commit-older".to_string(),
publication_gate: "bifrost".to_string(),
durable_state_admitted: true,
source_store_path: "state/runtime.cc".to_string(),
tui_rows: vec!["MAP test-item older".to_string()],
private_state_exposed: false,
notes: Vec::new(),
modeling_finding_receipt_id: "modeling-finding-older".to_string(),
modeling_route_id: "modeling-route-older".to_string(),
modeling_generation: 1,
};
let mut newer = older.clone();
newer.map_entry_id = "repo-work-map-newer".to_string();
newer.admitted_at = "2026-07-13T02:00:00Z".to_string();
newer.mirrored_at = "2026-07-13T02:00:01Z".to_string();
newer.commit_sha = "newer".to_string();
newer.modeling_generation = 2;
write_epiphany_cultmesh_repo_work_map_entry(&store, newer.clone())?;
write_epiphany_cultmesh_repo_work_map_entry(&store, older.clone())?;
assert_eq!(
load_latest_epiphany_cultmesh_repo_work_map_entry(&store, "repo-work-test")?,
Some(newer)
);
let mut impossible = older;
impossible.map_entry_id = "repo-work-map-impossible".to_string();
impossible.mirrored_at = "2026-07-13T00:59:59Z".to_string();
let err = write_epiphany_cultmesh_repo_work_map_entry(&store, impossible)
.expect_err("map projection before Mind admission must be refused");
assert!(err.to_string().contains("before Mind admission"));
Ok(())
}
#[test]
fn repo_work_overview_latest_follows_generation_not_arrival() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("repo-work-overview-order.ccmp");
let older = EpiphanyCultMeshRepoWorkOverviewEntry {
schema_version: EPIPHANY_CULTMESH_REPO_WORK_OVERVIEW_SCHEMA_VERSION.to_string(),
runtime_id: "repo-work-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
overview_id: "repo-work-overview-older".to_string(),
generated_at: "2026-07-13T01:00:00Z".to_string(),
workspace: "E:/Projects/test".to_string(),
item: "older-item".to_string(),
branch: "main".to_string(),
current_gate: "awaiting-plan".to_string(),
blocker: "plan-missing".to_string(),
next_safe_move: "derive plan".to_string(),
changed_paths: Vec::new(),
commit_sha: String::new(),
soul_verdict: "missing".to_string(),
publication_status: "not-started".to_string(),
sync_status: "not-started".to_string(),
receipt_refs: Vec::new(),
tui_rows: vec!["OVERVIEW older-item awaiting-plan".to_string()],
proof_bundle_ref: "proof://older".to_string(),
private_state_exposed: false,
notes: Vec::new(),
};
let mut newer = older.clone();
newer.overview_id = "repo-work-overview-newer".to_string();
newer.item = "newer-item".to_string();
newer.generated_at = "2026-07-13T02:00:00Z".to_string();
newer.current_gate = "ready-to-run".to_string();
newer.blocker = "none".to_string();
newer.next_safe_move = "run tick".to_string();
write_epiphany_cultmesh_repo_work_overview(&store, newer.clone())?;
write_epiphany_cultmesh_repo_work_overview(&store, older.clone())?;
assert_eq!(
load_latest_epiphany_cultmesh_repo_work_overview(&store, "repo-work-test")?,
Some(newer)
);
let mut invalid = older;
invalid.overview_id = "repo-work-overview-invalid".to_string();
invalid.generated_at = "not-a-time".to_string();
let err = write_epiphany_cultmesh_repo_work_overview(&store, invalid)
.expect_err("invalid overview generation time must be refused");
assert!(err.to_string().contains("invalid generated_at"));
Ok(())
}
#[test]
fn repo_work_readiness_latest_follows_generation_not_arrival() -> Result<()> {
let temp = tempfile::tempdir()?;
let store = temp.path().join("repo-work-readiness-order.ccmp");
let older = EpiphanyCultMeshRepoWorkReadinessEntry {
schema_version: EPIPHANY_CULTMESH_REPO_WORK_READINESS_SCHEMA_VERSION.to_string(),
runtime_id: "repo-work-test".to_string(),
verse_id: EPIPHANY_CULTMESH_LOCAL_AREA_VERSE_ID.to_string(),
readiness_id: "repo-work-readiness-older".to_string(),
generated_at: "2026-07-13T01:00:00Z".to_string(),
workspace: "E:/Projects/test".to_string(),
item: "older-item".to_string(),
status: "incomplete".to_string(),
missing_required_count: 1,
satisfied_required_count: 2,
readiness_receipt_ref: "receipt://older".to_string(),
overview_receipt_ref: "overview://older".to_string(),
proof_bundle_id: "proof-older".to_string(),
missing_kinds: vec!["maintainer-review".to_string()],
tui_rows: vec!["READINESS older-item incomplete".to_string()],
sight_only: true,
readiness_approval_authorized: false,
publication_authorized: false,
service_lifecycle_authority: false,
hands_action_authorized: false,
private_state_exposed: false,
notes: Vec::new(),
};
let mut newer = older.clone();
newer.readiness_id = "repo-work-readiness-newer".to_string();
newer.item = "newer-item".to_string();
newer.generated_at = "2026-07-13T02:00:00Z".to_string();
newer.status = "ready".to_string();
newer.missing_required_count = 0;
newer.satisfied_required_count = 3;
newer.missing_kinds.clear();
write_epiphany_cultmesh_repo_work_readiness(&store, newer.clone())?;
write_epiphany_cultmesh_repo_work_readiness(&store, older.clone())?;
assert_eq!(
load_latest_epiphany_cultmesh_repo_work_readiness(&store, "repo-work-test")?,
Some(newer)
);
let mut invalid = older;
invalid.readiness_id = "repo-work-readiness-invalid".to_string();
invalid.generated_at = "not-a-time".to_string();
let err = write_epiphany_cultmesh_repo_work_readiness(&store, invalid)
.expect_err("invalid readiness generation time must be refused");
assert!(err.to_string().contains("invalid generated_at"));
Ok(())
}
#[test]
fn scheduler_latest_mirror_refuses_delayed_replay() -> Result<()> {
let temp = tempfile::tempdir()?;
@ -9783,22 +9323,6 @@ mod tests {
private_state_exposed: false,
notes: vec!["redacted proof".to_string()],
};
let mut newer_proof = proof.clone();
newer_proof.public_proof_id = "repo-work-public-proof-newer".to_string();
newer_proof.generated_at = "2026-06-20T13:00:00Z".to_string();
newer_proof.commit_sha = "def456".to_string();
write_epiphany_cultmesh_repo_work_public_proof(&store, newer_proof.clone())?;
write_epiphany_cultmesh_repo_work_public_proof(&store, proof.clone())?;
assert_eq!(
load_latest_epiphany_cultmesh_repo_work_public_proof(&store, "epiphany-test")?,
Some(newer_proof)
);
let mut invalid_time = proof.clone();
invalid_time.public_proof_id = "repo-work-public-proof-invalid".to_string();
invalid_time.generated_at = "not-a-time".to_string();
let error = write_epiphany_cultmesh_repo_work_public_proof(&store, invalid_time)
.expect_err("invalid public proof generation time must be refused");
assert!(error.to_string().contains("invalid generated_at"));
let receipt = epiphany_cultmesh_bifrost_public_proof_publication_receipt_for_proof(
"bifrost-public-proof-publication-test",
&proof,

View file

@ -17,7 +17,6 @@ mod hands_gateway;
mod heartbeat_state;
mod memory_graph;
mod mind_gateway;
mod modeling_gateway;
mod organ_dependencies;
mod persona_memory_cache;
mod persona_turn;
@ -505,10 +504,6 @@ pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_intent;
pub use cultmesh_integration::write_epiphany_cultmesh_operator_run_receipt;
pub use cultmesh_integration::write_epiphany_cultmesh_operator_snapshot;
pub use cultmesh_integration::write_epiphany_cultmesh_persona_speech_audit;
pub use cultmesh_integration::write_epiphany_cultmesh_repo_work_map_entry;
pub use cultmesh_integration::write_epiphany_cultmesh_repo_work_overview;
pub use cultmesh_integration::write_epiphany_cultmesh_repo_work_public_proof;
pub use cultmesh_integration::write_epiphany_cultmesh_repo_work_readiness;
pub use cultmesh_integration::write_epiphany_cultmesh_role_review_event;
pub use cultmesh_integration::write_epiphany_cultmesh_soul_contracts;
pub use cultmesh_integration::write_epiphany_cultmesh_status;
@ -662,31 +657,12 @@ pub use mind_gateway::MindGatewayDecision;
pub use mind_gateway::MindGatewayReview;
pub use mind_gateway::MindInterpreterPromptInput;
pub use mind_gateway::MindStateCommitReceipt;
pub use mind_gateway::REPO_WORK_HANDS_GRANT_SCHEMA_VERSION;
pub use mind_gateway::REPO_WORK_HANDS_GRANT_TYPE;
pub use mind_gateway::REPO_WORK_PLAN_ADOPTION_REVIEW_SCHEMA_VERSION;
pub use mind_gateway::REPO_WORK_PLAN_ADOPTION_REVIEW_TYPE;
pub use mind_gateway::RepoWorkHandsGrant;
pub use mind_gateway::RepoWorkPlanAdoptionDecision;
pub use mind_gateway::RepoWorkPlanAdoptionReview;
pub use mind_gateway::build_mind_interpreter_prompt;
pub use mind_gateway::default_mind_cultnet_contracts;
pub use mind_gateway::mind_review_allows_state;
pub use mind_gateway::mind_review_reorient_acceptance;
pub use mind_gateway::mind_review_role_acceptance;
pub use mind_gateway::mind_state_commit_receipt;
pub use modeling_gateway::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION;
pub use modeling_gateway::REPO_WORK_MAP_ENTRY_TYPE;
pub use modeling_gateway::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION;
pub use modeling_gateway::REPO_WORK_MODELING_FINDING_TYPE;
pub use modeling_gateway::REPO_WORK_MODELING_REQUEST_SCHEMA_VERSION;
pub use modeling_gateway::REPO_WORK_MODELING_REQUEST_TYPE;
pub use modeling_gateway::REPO_WORK_MODELING_ROUTE_SCHEMA_VERSION;
pub use modeling_gateway::REPO_WORK_MODELING_ROUTE_TYPE;
pub use modeling_gateway::RepoWorkMapEntry;
pub use modeling_gateway::RepoWorkModelingFinding;
pub use modeling_gateway::RepoWorkModelingRequest;
pub use modeling_gateway::RepoWorkModelingRoute;
pub use organ_dependencies::EPIPHANY_LAUNCH_ORGAN_CONTRACT_SCHEMA_VERSION;
pub use organ_dependencies::EPIPHANY_ORGAN_DEPENDENCY_SCHEMA_VERSION;
pub use organ_dependencies::EPIPHANY_STANDING_ORGANS;
@ -799,15 +775,11 @@ pub use runtime_spine::RuntimeSpineInitOptions;
pub use runtime_spine::RuntimeSpineJobOptions;
pub use runtime_spine::RuntimeSpineJobResultOptions;
pub use runtime_spine::RuntimeSpineSessionOptions;
pub use runtime_spine::advance_repo_work_modeling_route;
pub use runtime_spine::append_runtime_event;
pub use runtime_spine::clear_epiphany_job_binding_backend;
pub use runtime_spine::commit_initial_repo_work_modeling_route;
pub use runtime_spine::commit_repo_frontier_modeling_request;
pub use runtime_spine::commit_repo_frontier_verification_request_for_chain;
pub use runtime_spine::commit_repo_model_admission;
pub use runtime_spine::commit_repo_work_hands_grant;
pub use runtime_spine::commit_repo_work_map_admission;
pub use runtime_spine::complete_runtime_job;
pub use runtime_spine::create_runtime_job;
pub use runtime_spine::create_runtime_session;
@ -831,9 +803,6 @@ pub use runtime_spine::put_mind_gateway_review;
pub use runtime_spine::put_mind_state_commit_receipt;
pub use runtime_spine::put_repo_frontier_hands_authority;
pub use runtime_spine::put_repo_frontier_verification_request;
pub use runtime_spine::put_repo_work_modeling_finding;
pub use runtime_spine::put_repo_work_modeling_request;
pub use runtime_spine::put_repo_work_plan_adoption_review;
pub use runtime_spine::put_runtime_reorient_worker_result;
pub use runtime_spine::put_runtime_role_worker_result;
pub use runtime_spine::put_soul_verdict_receipt;
@ -858,12 +827,6 @@ pub use runtime_spine::runtime_registered_document_types;
pub use runtime_spine::runtime_reorient_worker_result;
pub use runtime_spine::runtime_repo_frontier_route;
pub use runtime_spine::runtime_repo_frontier_verification_request;
pub use runtime_spine::runtime_repo_work_hands_grant;
pub use runtime_spine::runtime_repo_work_map_entry;
pub use runtime_spine::runtime_repo_work_modeling_finding;
pub use runtime_spine::runtime_repo_work_modeling_request;
pub use runtime_spine::runtime_repo_work_modeling_route;
pub use runtime_spine::runtime_repo_work_plan_adoption_review;
pub use runtime_spine::runtime_role_worker_result;
pub use runtime_spine::runtime_schema_catalog_response;
pub use runtime_spine::runtime_soul_verdict_receipt;
@ -972,7 +935,6 @@ pub use surfaces::EpiphanyReorientPressureLevel;
pub use surfaces::EpiphanyReorientReason;
pub use surfaces::EpiphanyReorientStateStatus;
pub use surfaces::EpiphanyReorientWorkerLaunchDocument;
pub use surfaces::EpiphanyRepoWorkModelingLaunchDocument;
pub use surfaces::EpiphanyRetrievalFreshness;
pub use surfaces::EpiphanyRetrievalFreshnessStatus;
pub use surfaces::EpiphanyRoleAcceptanceFinding;
@ -1005,7 +967,6 @@ pub use surfaces::EpiphanyTokenUsageSnapshot;
pub use surfaces::EpiphanyViewLens;
pub use surfaces::EpiphanyWorkerLaunchDocument;
pub use surfaces::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID;
pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::build_reorient_acceptance_bundle;
pub use surfaces::build_reorient_job_launch_request;

View file

@ -22,119 +22,6 @@ pub const MIND_STATE_REJECTION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.state_rejection_receipt.v0";
pub const MIND_VERSE_ADOPTION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.verse_adoption_receipt.v0";
pub const REPO_WORK_PLAN_ADOPTION_REVIEW_TYPE: &str = "epiphany.repo_work.plan_adoption_review";
pub const REPO_WORK_PLAN_ADOPTION_REVIEW_SCHEMA_VERSION: &str =
"epiphany.repo_work_plan_adoption_review.v0";
pub const REPO_WORK_HANDS_GRANT_TYPE: &str = "epiphany.repo_work.hands_grant";
pub const REPO_WORK_HANDS_GRANT_SCHEMA_VERSION: &str = "epiphany.repo_work_hands_grant.v0";
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum RepoWorkPlanAdoptionDecision {
Adopt,
Refuse,
Hold,
}
/// Mind-authored review of one immutable repo-work plan and its complete authority chain.
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.repo_work.plan_adoption_review",
schema = "RepoWorkPlanAdoptionReview"
)]
pub struct RepoWorkPlanAdoptionReview {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub review_id: String,
#[cultcache(key = 2)]
pub decision: RepoWorkPlanAdoptionDecision,
#[cultcache(key = 3)]
pub workspace_identity: String,
#[cultcache(key = 4)]
pub item: String,
#[cultcache(key = 5)]
pub plan_schema_version: String,
#[cultcache(key = 6)]
pub plan_id: String,
#[cultcache(key = 7)]
pub plan_sha256: String,
#[cultcache(key = 8)]
pub run_receipt_sha256: String,
#[cultcache(key = 9)]
pub plan_receipt_path: String,
#[cultcache(key = 10)]
pub run_receipt_path: String,
#[cultcache(key = 11)]
pub hands_intent_id: String,
#[cultcache(key = 12)]
pub queued_hands_review_id: String,
#[cultcache(key = 13)]
pub substrate_grant_receipt_id: String,
#[cultcache(key = 14)]
pub action_id: String,
#[cultcache(key = 15)]
pub action_command: String,
#[cultcache(key = 16)]
pub action_commit_message: String,
#[cultcache(key = 17)]
pub changed_paths: Vec<String>,
#[cultcache(key = 18)]
pub reviewed_at: String,
#[cultcache(key = 19)]
pub private_state_exposed: bool,
}
/// The only capability that converts an accepted Mind review into Hands authority.
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "epiphany.repo_work.hands_grant", schema = "RepoWorkHandsGrant")]
pub struct RepoWorkHandsGrant {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub grant_id: String,
#[cultcache(key = 2)]
pub adoption_review_id: String,
#[cultcache(key = 3)]
pub adoption_review_sha256: String,
#[cultcache(key = 4)]
pub workspace_identity: String,
#[cultcache(key = 5)]
pub item: String,
#[cultcache(key = 6)]
pub plan_id: String,
#[cultcache(key = 7)]
pub plan_sha256: String,
#[cultcache(key = 8)]
pub run_receipt_sha256: String,
#[cultcache(key = 9)]
pub plan_receipt_path: String,
#[cultcache(key = 10)]
pub run_receipt_path: String,
#[cultcache(key = 11)]
pub hands_intent_id: String,
#[cultcache(key = 12)]
pub queued_hands_review_id: String,
#[cultcache(key = 13)]
pub approved_hands_review_id: String,
#[cultcache(key = 14)]
pub substrate_grant_receipt_id: String,
#[cultcache(key = 15)]
pub action_id: String,
#[cultcache(key = 16)]
pub action_command: String,
#[cultcache(key = 17)]
pub action_commit_message: String,
#[cultcache(key = 18)]
pub allowed_operations: Vec<String>,
#[cultcache(key = 19)]
pub changed_paths: Vec<String>,
#[cultcache(key = 20)]
pub granted_at: String,
#[cultcache(key = 21)]
pub private_state_exposed: bool,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum MindGatewayDecision {

View file

@ -1,155 +0,0 @@
use cultcache_rs::DatabaseEntry;
pub const REPO_WORK_MODELING_FINDING_TYPE: &str = "epiphany.modeling.repo_work_finding";
pub const REPO_WORK_MODELING_FINDING_SCHEMA_VERSION: &str =
"epiphany.modeling.repo_work_finding.v0";
pub const REPO_WORK_MODELING_REQUEST_TYPE: &str = "epiphany.modeling.repo_work_request";
pub const REPO_WORK_MODELING_REQUEST_SCHEMA_VERSION: &str =
"epiphany.modeling.repo_work_request.v0";
pub const REPO_WORK_MODELING_ROUTE_TYPE: &str = "epiphany.modeling.repo_work_route";
pub const REPO_WORK_MODELING_ROUTE_SCHEMA_VERSION: &str = "epiphany.modeling.repo_work_route.v0";
pub const REPO_WORK_MAP_ENTRY_TYPE: &str = "epiphany.repo_work.map_entry";
pub const REPO_WORK_MAP_ENTRY_SCHEMA_VERSION: &str = "epiphany.repo_work.map_entry.v0";
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.modeling.repo_work_finding",
schema = "RepoWorkModelingFinding"
)]
pub struct RepoWorkModelingFinding {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub receipt_id: String,
#[cultcache(key = 2)]
pub item: String,
#[cultcache(key = 3)]
pub model_ref: String,
#[cultcache(key = 4)]
pub soul_verdict_receipt_id: String,
#[cultcache(key = 5)]
pub verdict: String,
#[cultcache(key = 6)]
pub finding: String,
#[cultcache(key = 7)]
pub summary: String,
#[cultcache(key = 8)]
pub changed_paths: Vec<String>,
#[cultcache(key = 9)]
pub commit_sha: String,
#[cultcache(key = 10)]
pub emitted_at: String,
#[cultcache(key = 11)]
pub private_state_exposed: bool,
#[cultcache(key = 12)]
pub contract: String,
#[cultcache(key = 13)]
pub request_id: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.modeling.repo_work_request",
schema = "RepoWorkModelingRequest"
)]
pub struct RepoWorkModelingRequest {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub request_id: String,
#[cultcache(key = 2)]
pub item: String,
#[cultcache(key = 3)]
pub requester: String,
#[cultcache(key = 4)]
pub soul_verdict_receipt_id: String,
#[cultcache(key = 5)]
pub commit_sha: String,
#[cultcache(key = 6)]
pub changed_paths: Vec<String>,
#[cultcache(key = 7)]
pub instruction: String,
#[cultcache(key = 8)]
pub requested_at: String,
#[cultcache(key = 9)]
pub private_state_exposed: bool,
#[cultcache(key = 10)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(
type = "epiphany.modeling.repo_work_route",
schema = "RepoWorkModelingRoute"
)]
pub struct RepoWorkModelingRoute {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub route_id: String,
#[cultcache(key = 2)]
pub item: String,
#[cultcache(key = 3)]
pub generation: u64,
#[cultcache(key = 4)]
pub request_id: String,
#[cultcache(key = 5)]
pub previous_finding_receipt_id: String,
#[cultcache(key = 6)]
pub authority_owner: String,
#[cultcache(key = 7)]
pub authority_witness_id: String,
#[cultcache(key = 8)]
pub updated_at: String,
#[cultcache(key = 9)]
pub private_state_exposed: bool,
#[cultcache(key = 10)]
pub contract: String,
}
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
#[cultcache(type = "epiphany.repo_work.map_entry", schema = "RepoWorkMapEntry")]
pub struct RepoWorkMapEntry {
#[cultcache(key = 0)]
pub schema_version: String,
#[cultcache(key = 1)]
pub map_entry_id: String,
#[cultcache(key = 2)]
pub admitted_at: String,
#[cultcache(key = 3)]
pub item: String,
#[cultcache(key = 4)]
pub branch: String,
#[cultcache(key = 5)]
pub changed_paths: Vec<String>,
#[cultcache(key = 6)]
pub commit_sha: String,
#[cultcache(key = 7)]
pub safe_action_family: String,
#[cultcache(key = 8)]
pub modeling_summary: String,
#[cultcache(key = 9)]
pub modeling_finding_receipt_id: String,
#[cultcache(key = 10)]
pub soul_verdict_receipt_id: String,
#[cultcache(key = 11)]
pub mind_gateway_review_id: String,
#[cultcache(key = 12)]
pub mind_state_commit_receipt_id: String,
#[cultcache(key = 13)]
pub execute_receipt_path: String,
#[cultcache(key = 14)]
pub closure_review_path: String,
#[cultcache(key = 15)]
pub closure_receipt_path: String,
#[cultcache(key = 16)]
pub publication_gate: String,
#[cultcache(key = 17)]
pub durable_state_admitted: bool,
#[cultcache(key = 18)]
pub private_state_exposed: bool,
#[cultcache(key = 19)]
pub modeling_route_id: String,
#[cultcache(key = 20)]
pub modeling_generation: u64,
}

File diff suppressed because it is too large Load diff

View file

@ -141,10 +141,8 @@ pub use view::epiphany_view_needs_reorientation_inputs;
pub use view::epiphany_view_needs_runtime_store;
pub use worker_launch::EpiphanyReorientLaunchRequestInput;
pub use worker_launch::EpiphanyReorientWorkerLaunchDocument;
pub use worker_launch::EpiphanyRepoWorkModelingLaunchDocument;
pub use worker_launch::EpiphanyRoleWorkerLaunchDocument;
pub use worker_launch::EpiphanyWorkerLaunchDocument;
pub use worker_launch::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
pub use worker_launch::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID;
pub use worker_launch::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use worker_launch::build_reorient_job_launch_request;

View file

@ -26,15 +26,12 @@ use crate::EpiphanyReorientReason;
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v0";
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
pub const REPO_WORK_MODELING_OUTPUT_CONTRACT_ID: &str =
"epiphany.worker.repo_work_modeling_result.v0";
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", tag = "documentKind")]
pub enum EpiphanyWorkerLaunchDocument {
Role(EpiphanyRoleWorkerLaunchDocument),
Reorient(EpiphanyReorientWorkerLaunchDocument),
RepoWorkModeling(EpiphanyRepoWorkModelingLaunchDocument),
}
impl EpiphanyWorkerLaunchDocument {
@ -42,7 +39,6 @@ impl EpiphanyWorkerLaunchDocument {
match self {
Self::Role(_) => ROLE_WORKER_OUTPUT_CONTRACT_ID,
Self::Reorient(_) => REORIENT_WORKER_OUTPUT_CONTRACT_ID,
Self::RepoWorkModeling(_) => REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
}
}
@ -50,7 +46,6 @@ impl EpiphanyWorkerLaunchDocument {
match self {
Self::Role(_) => "role",
Self::Reorient(_) => "reorient",
Self::RepoWorkModeling(_) => "repo-work-modeling",
}
}
@ -58,7 +53,6 @@ impl EpiphanyWorkerLaunchDocument {
match self {
Self::Role(document) => &document.thread_id,
Self::Reorient(document) => &document.thread_id,
Self::RepoWorkModeling(document) => &document.thread_id,
}
}
@ -66,28 +60,12 @@ impl EpiphanyWorkerLaunchDocument {
match self {
Self::Role(document) => document.dynamic_prompt_context.as_deref(),
Self::Reorient(document) => document.dynamic_prompt_context.as_deref(),
Self::RepoWorkModeling(document) => document.dynamic_prompt_context.as_deref(),
}
.map(str::trim)
.filter(|context| !context.is_empty())
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyRepoWorkModelingLaunchDocument {
pub thread_id: String,
pub request_id: String,
pub item: String,
pub soul_verdict_receipt_id: String,
pub commit_sha: String,
#[serde(default)]
pub changed_paths: Vec<String>,
pub instruction: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub dynamic_prompt_context: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyRoleWorkerLaunchDocument {

View file

@ -659,34 +659,6 @@ pub fn complete_worker_job_from_assistant_text(
);
put_runtime_reorient_worker_result(store_path.as_ref(), &typed_result)?;
}
(
EpiphanyWorkerLaunchDocument::RepoWorkModeling(document),
WorkerResultIngress::RepoWorkModeling(parsed),
) => {
let typed_result = epiphany_core::RepoWorkModelingFinding {
schema_version: epiphany_core::REPO_WORK_MODELING_FINDING_SCHEMA_VERSION
.to_string(),
receipt_id: format!("{}-finding", document.request_id),
item: document.item.clone(),
model_ref: openai_request_id.to_string(),
soul_verdict_receipt_id: document.soul_verdict_receipt_id.clone(),
verdict: clean_optional_string(parsed.verdict.as_deref())
.unwrap_or_else(|| "failed".to_string()),
finding: clean_optional_string(parsed.finding.as_deref()).unwrap_or_else(|| {
"Modeling returned no bounded repo-work finding.".to_string()
}),
summary: clean_optional_string(parsed.summary.as_deref()).unwrap_or_else(|| {
"Modeling returned no repo-work summary.".to_string()
}),
changed_paths: document.changed_paths.clone(),
commit_sha: document.commit_sha.clone(),
emitted_at: now(),
private_state_exposed: false,
contract: "Model-authored interpretation of one typed Self request over a Soul-verified repo consequence.".to_string(),
request_id: document.request_id.clone(),
};
epiphany_core::put_repo_work_modeling_finding(store_path.as_ref(), &typed_result)?;
}
_ => {
return Err(anyhow!(
"worker launch document and parsed result kind diverged"
@ -1331,19 +1303,6 @@ fn worker_output_schema_json(document: &EpiphanyWorkerLaunchDocument) -> Result<
EpiphanyWorkerLaunchDocument::Reorient(_) => {
epiphany_core::epiphany_reorient_launch_output_schema()
}
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => serde_json::json!({
"type": "object",
"additionalProperties": false,
"required": ["verdict", "finding", "summary", "nextSafeMove", "evidenceIds"],
"properties": {
"verdict": { "type": "string", "enum": ["passed", "failed", "needs-work", "blocked"] },
"finding": { "type": "string", "minLength": 1 },
"summary": { "type": "string", "minLength": 1 },
"nextSafeMove": { "type": "string", "minLength": 1 },
"evidenceIds": { "type": "array", "items": { "type": "string" } },
"artifactRefs": { "type": "array", "items": { "type": "string" } }
}
}),
};
serde_json::to_string_pretty(&schema).context("failed to render worker output schema")
}
@ -1370,9 +1329,6 @@ fn worker_output_contract_text(document: &EpiphanyWorkerLaunchDocument) -> &'sta
EpiphanyWorkerLaunchDocument::Reorient(_) => {
"Required reorient-result fields: mode, summary, nextSafeMove. Include checkpointStillValid, filesInspected, frontierNodeIds, evidenceIds, openQuestions, and continuityRisks when present."
}
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => {
"Required repo-work Modeling fields: verdict, finding, summary, nextSafeMove, evidenceIds. Interpret only the Soul-verified consequence named by the request. Do not claim Mind admission, publication, merge, or further Hands authority."
}
}
}
@ -1415,22 +1371,10 @@ struct ReorientWorkerResultIngress {
continuity_risks: Vec<String>,
}
#[derive(Debug, Clone, Default, serde::Deserialize)]
#[serde(rename_all = "camelCase", default)]
struct RepoWorkModelingResultIngress {
verdict: Option<String>,
finding: Option<String>,
summary: Option<String>,
next_safe_move: Option<String>,
evidence_ids: Vec<String>,
artifact_refs: Vec<String>,
}
#[derive(Debug, Clone)]
enum WorkerResultIngress {
Role(RoleWorkerResultIngress),
Reorient(ReorientWorkerResultIngress),
RepoWorkModeling(RepoWorkModelingResultIngress),
}
impl WorkerResultIngress {
@ -1438,9 +1382,6 @@ impl WorkerResultIngress {
match self {
WorkerResultIngress::Role(result) => clean_optional_string(result.verdict.as_deref()),
WorkerResultIngress::Reorient(result) => clean_optional_string(result.mode.as_deref()),
WorkerResultIngress::RepoWorkModeling(result) => {
clean_optional_string(result.verdict.as_deref())
}
}
}
@ -1450,9 +1391,6 @@ impl WorkerResultIngress {
WorkerResultIngress::Reorient(result) => {
clean_optional_string(result.summary.as_deref())
}
WorkerResultIngress::RepoWorkModeling(result) => {
clean_optional_string(result.summary.as_deref())
}
}
}
@ -1464,9 +1402,6 @@ impl WorkerResultIngress {
WorkerResultIngress::Reorient(result) => {
clean_optional_string(result.next_safe_move.as_deref())
}
WorkerResultIngress::RepoWorkModeling(result) => {
clean_optional_string(result.next_safe_move.as_deref())
}
}
}
@ -1474,7 +1409,6 @@ impl WorkerResultIngress {
match self {
WorkerResultIngress::Role(result) => clean_string_vec(&result.evidence_ids),
WorkerResultIngress::Reorient(result) => clean_string_vec(&result.evidence_ids),
WorkerResultIngress::RepoWorkModeling(result) => clean_string_vec(&result.evidence_ids),
}
}
@ -1482,9 +1416,6 @@ impl WorkerResultIngress {
match self {
WorkerResultIngress::Role(result) => clean_string_vec(&result.artifact_refs),
WorkerResultIngress::Reorient(result) => clean_string_vec(&result.artifact_refs),
WorkerResultIngress::RepoWorkModeling(result) => {
clean_string_vec(&result.artifact_refs)
}
}
}
}
@ -1502,10 +1433,6 @@ fn parse_worker_result_ingress(
parse_assistant_json::<ReorientWorkerResultIngress>(assistant_text)
.map(WorkerResultIngress::Reorient)
}
EpiphanyWorkerLaunchDocument::RepoWorkModeling(_) => {
parse_assistant_json::<RepoWorkModelingResultIngress>(assistant_text)
.map(WorkerResultIngress::RepoWorkModeling)
}
}
}
@ -2054,282 +1981,6 @@ mod tests {
Ok(())
}
#[test]
fn repo_work_modeling_generation_retry_admits_only_current_runtime_finding() -> Result<()> {
let temp = tempdir()?;
let store = temp.path().join("runtime.msgpack");
initialize_runtime_spine(
&store,
RuntimeSpineInitOptions {
runtime_id: "repo-work-test".to_string(),
display_name: "Repo Work Test".to_string(),
created_at: now(),
},
)?;
epiphany_core::put_soul_verdict_receipt(
&store,
&epiphany_core::SoulVerdictReceipt {
schema_version: epiphany_core::SOUL_VERDICT_RECEIPT_SCHEMA_VERSION.to_string(),
receipt_id: "soul-repo-1".to_string(),
source_result_id: "hands-result-1".to_string(),
source_job_id: "hands-job-1".to_string(),
verdict: "passed".to_string(),
summary: "Soul passed.".to_string(),
evidence_ids: vec!["commit-abc".to_string()],
risks: Vec::new(),
emitted_at: now(),
contract: "test".to_string(),
verification_request_id: String::new(),
frontier_route_id: String::new(),
},
)?;
let request = epiphany_core::RepoWorkModelingRequest {
schema_version: epiphany_core::REPO_WORK_MODELING_REQUEST_SCHEMA_VERSION.to_string(),
request_id: "repo-request-1".to_string(),
item: "map-repo".to_string(),
requester: "self".to_string(),
soul_verdict_receipt_id: "soul-repo-1".to_string(),
commit_sha: "abc123".to_string(),
changed_paths: vec!["README.md".to_string()],
instruction: "Model the verified consequence.".to_string(),
requested_at: now(),
private_state_exposed: false,
contract: "test".to_string(),
};
let route0 = epiphany_core::RepoWorkModelingRoute {
schema_version: epiphany_core::REPO_WORK_MODELING_ROUTE_SCHEMA_VERSION.to_string(),
route_id: "repo-route-1".to_string(),
item: request.item.clone(),
generation: 0,
request_id: request.request_id.clone(),
previous_finding_receipt_id: String::new(),
authority_owner: "soul".to_string(),
authority_witness_id: request.soul_verdict_receipt_id.clone(),
updated_at: now(),
private_state_exposed: false,
contract: "test initial route".to_string(),
};
epiphany_core::commit_initial_repo_work_modeling_route(&store, &request, &route0)?;
open_runtime_spine_heartbeat_job(
&store,
RuntimeSpineHeartbeatJobOptions {
runtime_id: "repo-work-test".to_string(),
display_name: "Repo Work Test".to_string(),
session_id: "repo-session-1".to_string(),
objective: "Map repo work.".to_string(),
coordinator_note: "Self routes; Modeling authors.".to_string(),
job_id: "repo-modeling-job-1".to_string(),
role: "modeling".to_string(),
binding_id: "repo-work-modeling-worker".to_string(),
authority_scope: "epiphany.role.modeling.repo-work".to_string(),
instruction: "Return the required repo-work Modeling result.".to_string(),
launch_document: EpiphanyWorkerLaunchDocument::RepoWorkModeling(
epiphany_core::EpiphanyRepoWorkModelingLaunchDocument {
thread_id: "repo-thread-1".to_string(),
request_id: request.request_id.clone(),
item: request.item.clone(),
soul_verdict_receipt_id: request.soul_verdict_receipt_id.clone(),
commit_sha: request.commit_sha.clone(),
changed_paths: request.changed_paths.clone(),
instruction: request.instruction.clone(),
dynamic_prompt_context: None,
},
),
output_contract_id: epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID
.to_string(),
organ_launch_contract: epiphany_core::default_launch_organ_contract(
"epiphany.role.modeling.repo-work",
"repo-work-modeling",
epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
),
created_at: now(),
},
)?;
let launch = load_worker_launch_request(&store, "repo-modeling-job-1")?;
let model_request = build_worker_model_request(&launch, DEFAULT_MODEL_PROVIDER, "gpt-5.4")?;
assert_eq!(
model_request.output_contract_id.as_deref(),
Some(epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID)
);
assert!(
model_request
.output_schema_json
.as_deref()
.is_some_and(|schema| schema.contains("\"finding\""))
);
let openai_summary = EpiphanyOpenAiRuntimeRunSummary {
store: store.display().to_string(),
session_id: "openai-repo-session".to_string(),
job_id: "openai-repo-job".to_string(),
request_id: model_request.request_id.clone(),
event_count: 1,
verdict: "pass".to_string(),
summary: "completed".to_string(),
result_id: "openai-repo-result".to_string(),
receipt_id: Some(model_request.request_id.clone()),
tool_intent_ids: Vec::new(),
};
complete_worker_job_from_assistant_text(
&store,
&launch,
&model_request.request_id,
&openai_summary,
r#"{"verdict":"needs-work","finding":"The verified README consequence needs reviewed context.","summary":"Context incomplete.","nextSafeMove":"Ask Mind to review a retry.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#,
)?;
let finding0 =
epiphany_core::runtime_repo_work_modeling_finding(&store, "repo-request-1-finding")?
.expect("typed repo-work Modeling finding");
assert_eq!(finding0.request_id, request.request_id);
assert_eq!(finding0.verdict, "needs-work");
assert_eq!(finding0.commit_sha, "abc123");
assert!(!finding0.private_state_exposed);
let review = epiphany_core::MindGatewayReview {
schema_version: epiphany_core::MIND_GATEWAY_REVIEW_SCHEMA_VERSION.to_string(),
gateway_id: "repo-route-1-g1-review".to_string(),
source_kind: "repo_work_modeling_revision".to_string(),
source_role_id: "mind".to_string(),
decision: epiphany_core::MindGatewayDecision::Accept,
allowed_effects: vec!["repoWork.modelingRoute".to_string()],
refused_effects: vec!["repoWork.map".to_string()],
reasons: vec!["Reviewed the missing context.".to_string()],
contract: "test route review".to_string(),
};
let request1 = epiphany_core::RepoWorkModelingRequest {
request_id: "repo-request-2".to_string(),
requester: "mind".to_string(),
instruction: "Re-model with reviewed context.".to_string(),
requested_at: now(),
..request.clone()
};
let route1 = epiphany_core::RepoWorkModelingRoute {
generation: 1,
request_id: request1.request_id.clone(),
previous_finding_receipt_id: finding0.receipt_id.clone(),
authority_owner: "mind".to_string(),
authority_witness_id: review.gateway_id.clone(),
updated_at: now(),
..route0.clone()
};
epiphany_core::advance_repo_work_modeling_route(&store, &request1, &route1, &review)?;
open_runtime_spine_heartbeat_job(
&store,
RuntimeSpineHeartbeatJobOptions {
runtime_id: "repo-work-test".to_string(),
display_name: "Repo Work Test".to_string(),
session_id: "repo-session-1".to_string(),
objective: "Map reviewed repo work.".to_string(),
coordinator_note: "Mind selected generation one; Modeling authors.".to_string(),
job_id: "repo-modeling-job-2".to_string(),
role: "modeling".to_string(),
binding_id: "repo-work-modeling-worker".to_string(),
authority_scope: "epiphany.role.modeling.repo-work".to_string(),
instruction: "Return the reviewed repo-work Modeling result.".to_string(),
launch_document: EpiphanyWorkerLaunchDocument::RepoWorkModeling(
epiphany_core::EpiphanyRepoWorkModelingLaunchDocument {
thread_id: "repo-thread-1".to_string(),
request_id: request1.request_id.clone(),
item: request1.item.clone(),
soul_verdict_receipt_id: request1.soul_verdict_receipt_id.clone(),
commit_sha: request1.commit_sha.clone(),
changed_paths: request1.changed_paths.clone(),
instruction: request1.instruction.clone(),
dynamic_prompt_context: Some("Mind-reviewed generation one.".to_string()),
},
),
output_contract_id: epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID
.to_string(),
organ_launch_contract: epiphany_core::default_launch_organ_contract(
"epiphany.role.modeling.repo-work",
"repo-work-modeling",
epiphany_core::REPO_WORK_MODELING_OUTPUT_CONTRACT_ID,
),
created_at: now(),
},
)?;
let launch1 = load_worker_launch_request(&store, "repo-modeling-job-2")?;
let model_request1 =
build_worker_model_request(&launch1, DEFAULT_MODEL_PROVIDER, "gpt-5.4")?;
let openai_summary1 = EpiphanyOpenAiRuntimeRunSummary {
request_id: model_request1.request_id.clone(),
job_id: "openai-repo-job-2".to_string(),
result_id: "openai-repo-result-2".to_string(),
..openai_summary
};
complete_worker_job_from_assistant_text(
&store,
&launch1,
&model_request1.request_id,
&openai_summary1,
r#"{"verdict":"passed","finding":"The reviewed README consequence updates the repo map.","summary":"README consequence mapped.","nextSafeMove":"Let Mind admit generation one.","evidenceIds":["soul-repo-1"],"artifactRefs":[]}"#,
)?;
let finding1 =
epiphany_core::runtime_repo_work_modeling_finding(&store, "repo-request-2-finding")?
.expect("generation-one typed finding");
assert_eq!(finding1.verdict, "passed");
let map_review = epiphany_core::MindGatewayReview {
gateway_id: "repo-map-review".to_string(),
source_kind: "repo_work_closure".to_string(),
allowed_effects: vec!["repoWork.map".to_string()],
refused_effects: Vec::new(),
reasons: vec!["Admit current passing finding.".to_string()],
contract: "test map review".to_string(),
..review.clone()
};
let map_commit = epiphany_core::mind_state_commit_receipt(
"repo-map-commit".to_string(),
&map_review,
1,
vec!["repoWork.map".to_string()],
now(),
);
let map = epiphany_core::RepoWorkMapEntry {
schema_version: epiphany_core::REPO_WORK_MAP_ENTRY_SCHEMA_VERSION.to_string(),
map_entry_id: "repo-map-entry".to_string(),
admitted_at: now(),
item: request1.item.clone(),
branch: "test".to_string(),
changed_paths: request1.changed_paths.clone(),
commit_sha: request1.commit_sha.clone(),
safe_action_family: "repo.status_section".to_string(),
modeling_summary: finding1.summary.clone(),
modeling_finding_receipt_id: finding1.receipt_id.clone(),
soul_verdict_receipt_id: request1.soul_verdict_receipt_id.clone(),
mind_gateway_review_id: map_review.gateway_id.clone(),
mind_state_commit_receipt_id: map_commit.receipt_id.clone(),
execute_receipt_path: "execute.json".to_string(),
closure_review_path: "review.json".to_string(),
closure_receipt_path: "close.json".to_string(),
publication_gate: "Bifrost".to_string(),
durable_state_admitted: true,
private_state_exposed: false,
modeling_route_id: route1.route_id.clone(),
modeling_generation: 1,
};
epiphany_core::commit_repo_work_map_admission(&store, &map, &map_review, &map_commit)?;
let mut stale = map.clone();
stale.map_entry_id = "stale-generation-zero-map".to_string();
stale.modeling_finding_receipt_id = finding0.receipt_id.clone();
stale.modeling_summary = finding0.summary.clone();
stale.modeling_generation = 0;
assert!(
epiphany_core::commit_repo_work_map_admission(
&store,
&stale,
&map_review,
&map_commit,
)
.is_err()
);
let current_route =
epiphany_core::runtime_repo_work_modeling_route(&store, &route1.route_id)?
.expect("current route");
assert_eq!(current_route.generation, 1);
assert_eq!(current_route.request_id, request1.request_id);
Ok(())
}
#[test]
fn mcp_model_tool_call_becomes_typed_invocation_intent() -> Result<()> {
let event = EpiphanyModelStreamEvent {

View file

@ -91,6 +91,29 @@ that workflow on canonical RepoFrontier route/Hands/Soul/Modeling authority and
demote `RepoWorkMapEntry` to derived closure history. Do not let item-slug routes
or the legacy special Modeling worker close work independently of RepoModel.
Stage 1 of that convergence is now landed in the worktree and Soul-approved.
The parallel authority was cut before its replacement was enabled. Legacy
RepoWork Modeling request/route/finding/map types, worker launch, OpenAI ingress,
runtime writers, manual generation retry, Mind plan-adoption type, independent
Hands grant, CultMesh overview/readiness/public-proof writers, and closure
contract corpse are deleted. `epiphany-work` is an 82-line quarantine mouth:
every mutation/scheduling/publication command refuses before substrate access;
overview emits only an explicit `historical-only` non-authoritative projection.
Verse query cannot turn historical map rows into current gates, actions,
closure, acceptance, pending Bifrost requests, or accounting. Legitimate
Bifrost artifact-acceptance and metrics receipts still produce accounting rows
without consulting RepoWork history. The authoritative serial proof is core
294 passed/1 ignored, epiphany-work 1 passed, Verse query 13 passed, OpenAI
runtime 8 passed; independent Soul verdict is PASS.
The temporary outage is intentional. Do not resurrect old plan/run/adopt/
execute/close code to restore motion. The next build begins from the authority
map in `notes/repo-work-canonical-convergence.md`: inert proposal -> ordinary
Modeling frontier admission -> typed Self planning request -> Imagination plan
candidate -> Mind plan adoption -> distinct Self execution route -> canonical
Hands/Soul/verdict-incorporation chain. Plan readiness does not belong in
`RepoFrontierStatus`, and a generic phase router has not earned existence.
The next artifact-contract audit then cut `epiphany.persona_chat.v0`: its live
writer and catalog had disagreed on field vocabulary, evidence fields, and
lifecycle closure. The writer is now typed Rust with closed

View file

@ -0,0 +1,74 @@
# Repo-Work Canonical Convergence
## Objective
Preserve the branch-local repo-work user story without preserving its second
Modeling, Self, Hands, Soul, or Mind authority. Repo-work is a workflow over one
canonical `RepoFrontierItem`; it is not another repository model.
## Authority Map
- Owner: runtime-spine `RepoModel` owns repository anatomy and frontier
lifecycle.
- Inputs: an immutable work proposal; an admitted frontier identity; a typed
plan candidate and Mind adoption; the current model and route; immutable
Substrate/Hands consequences; Soul verification; Modeling verdict
incorporation; provider publication receipts.
- Outputs: one admitted frontier transition plus derived workflow/closure/public
proof projections.
- Derived state: filesystem plan/run/execute/close artifacts, operator rows,
closure history, and public proof bundles. They may explain or export the
canonical chain; they may not schedule, repair, or close it.
- Forbidden writers: item-slug route synthesis, `RepoWorkModelingRequest`,
`RepoWorkModelingRoute`, `RepoWorkModelingFinding`, `RepoWorkMapEntry`,
`revise-modeling`, plan-derived independent Hands grants, JSON-existence phase
selection, and local Verse map rows that claim current anatomy.
- Shared path: `proposal -> Modeling Evolution -> Mind frontier admission -> Self
planning request -> Imagination plan candidate -> Mind plan adoption -> Self
execution route -> Hands authority/consequence -> Soul verification -> Modeling
verdict incorporation -> Mind final admission -> derived closure/public proof`.
- Deletion line: legacy Modeling/map writers and scheduler routes are cut before
new execution is enabled. Historical documents may remain readable only as
inert history.
## Organ Ownership
- Modeling authors repository claims and frontier proposals; it does not author
commands or adopt its own output.
- Self emits a typed planning request bound to one current frontier id/hash and
assigns Imagination. This is not an execution route.
- Imagination authors a candidate response bound to that planning request.
- Mind admits the exact plan candidate.
- Self then emits a distinct execution route that freezes the current model,
frontier item, and adopted plan for Hands. Do not generalize both phases into
a generic router until a shared invariant actually earns that abstraction.
- Hands acts only from that route and the Substrate grant.
- Soul judges the exact consequence chain.
- Modeling incorporates Soul's verdict into the same frontier item; Mind admits
the transition.
- Bifrost/provider receipts own publication and merge truth.
## Bootstrap
Persona/intake emits an immutable proposal, not a work item. Ordinary Modeling
may cite that proposal in an Evolution patch that creates the frontier item.
Mind admission makes the wound real. Plan/adopt requires that admitted frontier
identity; no CLI slug, filesystem path, or old close receipt may synthesize it.
## Rebuild Order
1. **Landed:** refuse and delete new legacy repo-work Modeling/map mutations,
retry routes, worker ingress, independent plan-adoption/Hands grant,
scheduler/publication authority, and current-looking CultMesh writers.
Historical readers are sight-only and cannot feed gates, actions, closure,
pending Bifrost requests, or accounting. Temporary workflow outage is honest.
2. Add typed proposal-to-frontier bootstrap through ordinary Modeling/Mind.
3. Add typed Self planning request, frontier plan candidate/adoption, and bind
plan identity into the later Self execution route plus Hands authority.
Re-enable execution only through that chain.
4. Rewire verification/closure through canonical Soul and verdict incorporation.
5. Rebuild closure/public proof as read-only joins, then delete stale map schemas
and projection keys.
Do not encode plan readiness in `RepoFrontierStatus`. The model owns the wound;
the plan owns a proposed response; Self owns their binding.

Binary file not shown.

View file

@ -661,4 +661,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: Converge the legacy RepoWork closure workflow on the accepted canonical RepoModel organ loop. The first causal slice is now proven: typed Modeling patch and Mind admission; Self route bound to current model/frontier identity; immutable Substrate/Hands consequence chain; exact Soul verification request and verdict; typed Modeling verdict-incorporation request; pass-to-Resolved and nonpass-to-Blocked; no unrouted Hands default; full-chain replay at final CAS; atomic absent-only companions; recoverable split coordinator retry; hostile substitution/race/nonselection proof; Soul PASS. Do not add index polish or another adapter. Keep repo-work plan/adopt/execute only where it serves the branch-local workflow, require it to consume canonical RepoFrontierRoute and RepoFrontierHandsAuthority, delete the special RepoWorkModeling Request/Route/Finding worker protocol and item-slug retry route, and demote or rename RepoWorkMapEntry as derived closure history with no anatomy/routing authority. Then add typed Eyes challenges and Imagination campaign revisions so Blocked persistence becomes real Aetheria-style corrective circulation rather than a terminal note. The intentionally absent Other-world action still requires a typed intent and real owner. Keep closure's zero-substring invariant.
next_action: Build canonical repo-work planning on the purified RepoModel loop; do not restore the deleted legacy workflow. Stage 1 is Soul-approved and intentionally fail-closed: RepoWork Modeling/map worker authority, plan-adoption/independent Hands grant, closure contracts, scheduler/publication writers, and live history-derived Bifrost/accounting decisions are deleted; epiphany-work is a warning-clean quarantine mouth and historical Verse rows are sight-only. Start with an immutable inert work proposal. Ordinary Modeling cites it in an Evolution patch that creates one frontier item; Mind admission makes the wound real. Self then emits a typed planning request bound to the current frontier id/hash and assigns Imagination; Imagination emits a typed plan candidate; Mind adopts the exact candidate; a distinct Self execution route freezes model, frontier, and adopted plan for canonical Hands authority. Only then re-enable execution, Soul verification, verdict incorporation, derived closure, and public proof. Do not put plan readiness in RepoFrontierStatus, invent a generic phase router, infer identity from an item slug, or add a compatibility adapter. Then add typed Eyes challenges so Blocked pressure can circulate. The intentionally absent Other-world action still requires a typed intent and real owner. Keep closure's zero-substring invariant.