Advertise interactive CultNet surface contracts

This commit is contained in:
Meta Vens 2026-05-07 08:27:51 +01:00
commit 0b08863b95
4 changed files with 307 additions and 10 deletions

View file

@ -22,8 +22,42 @@ pub const RUNTIME_SESSION_TYPE: &str = "epiphany.runtime.session";
pub const RUNTIME_JOB_TYPE: &str = "epiphany.runtime.job";
pub const RUNTIME_JOB_RESULT_TYPE: &str = "epiphany.runtime.job_result";
pub const RUNTIME_EVENT_TYPE: &str = "epiphany.runtime.event";
pub const SURFACE_SCENE_TYPE: &str = "epiphany.surface.scene";
pub const SURFACE_PRESSURE_TYPE: &str = "epiphany.surface.pressure";
pub const SURFACE_REORIENT_TYPE: &str = "epiphany.surface.reorient";
pub const SURFACE_CRRC_TYPE: &str = "epiphany.surface.crrc";
pub const SURFACE_JOBS_TYPE: &str = "epiphany.surface.jobs";
pub const SURFACE_ROLES_TYPE: &str = "epiphany.surface.roles";
pub const SURFACE_ROLE_RESULT_TYPE: &str = "epiphany.surface.role_result";
pub const SURFACE_REORIENT_RESULT_TYPE: &str = "epiphany.surface.reorient_result";
pub const SURFACE_PLANNING_TYPE: &str = "epiphany.surface.planning";
pub const SURFACE_COORDINATOR_TYPE: &str = "epiphany.surface.coordinator";
pub const SURFACE_FACE_TYPE: &str = "epiphany.surface.face";
pub const SURFACE_VOID_MEMORY_TYPE: &str = "epiphany.surface.void_memory";
pub const SURFACE_REPO_INITIALIZATION_TYPE: &str = "epiphany.surface.repo_initialization";
pub const SURFACE_REPO_BIRTH_RUNNER_TYPE: &str = "epiphany.surface.repo_birth_runner";
pub const SURFACE_RIDER_BRIDGE_TYPE: &str = "epiphany.surface.rider_bridge";
pub const SURFACE_UNITY_BRIDGE_TYPE: &str = "epiphany.surface.unity_bridge";
pub const RUNTIME_IDENTITY_KEY: &str = "self";
pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v0";
pub const SCENE_SURFACE_SCHEMA_VERSION: &str = "epiphany.scene_surface.v0";
pub const PRESSURE_SURFACE_SCHEMA_VERSION: &str = "epiphany.pressure_surface.v0";
pub const REORIENT_SURFACE_SCHEMA_VERSION: &str = "epiphany.reorient_surface.v0";
pub const CRRC_SURFACE_SCHEMA_VERSION: &str = "epiphany.crrc_surface.v0";
pub const JOBS_SURFACE_SCHEMA_VERSION: &str = "epiphany.jobs_surface.v0";
pub const ROLES_SURFACE_SCHEMA_VERSION: &str = "epiphany.roles_surface.v0";
pub const ROLE_RESULT_SURFACE_SCHEMA_VERSION: &str = "epiphany.role_result_surface.v0";
pub const REORIENT_RESULT_SURFACE_SCHEMA_VERSION: &str = "epiphany.reorient_result_surface.v0";
pub const PLANNING_SURFACE_SCHEMA_VERSION: &str = "epiphany.planning_surface.v0";
pub const COORDINATOR_SURFACE_SCHEMA_VERSION: &str = "epiphany.coordinator_surface.v0";
pub const FACE_SURFACE_SCHEMA_VERSION: &str = "epiphany.face_surface.v0";
pub const VOID_MEMORY_SURFACE_SCHEMA_VERSION: &str = "epiphany.void_memory_surface.v0";
pub const REPO_INITIALIZATION_SURFACE_SCHEMA_VERSION: &str =
"epiphany.repo_initialization_surface.v0";
pub const REPO_BIRTH_RUNNER_SURFACE_SCHEMA_VERSION: &str =
"epiphany.repo_birth_runner_surface.v0";
pub const RIDER_BRIDGE_SURFACE_SCHEMA_VERSION: &str = "epiphany.rider_bridge_surface.v0";
pub const UNITY_BRIDGE_SURFACE_SCHEMA_VERSION: &str = "epiphany.unity_bridge_surface.v0";
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
#[cultcache(type = "epiphany.runtime.identity", schema = "EpiphanyRuntimeIdentity")]
@ -653,16 +687,13 @@ fn require_identity(cache: &CultCache) -> Result<EpiphanyRuntimeIdentity> {
}
fn supported_runtime_document_types() -> Vec<String> {
vec![
RUNTIME_IDENTITY_TYPE.to_string(),
RUNTIME_SESSION_TYPE.to_string(),
RUNTIME_JOB_TYPE.to_string(),
RUNTIME_JOB_RESULT_TYPE.to_string(),
RUNTIME_EVENT_TYPE.to_string(),
"epiphany.agent.memory".to_string(),
"epiphany.heartbeat.state".to_string(),
"epiphany.state_ledger".to_string(),
]
let mut document_types = Vec::new();
for contract in epiphany_mutation_contracts() {
if !document_types.contains(&contract.document_type) {
document_types.push(contract.document_type);
}
}
document_types
}
fn mutation_contract(
@ -695,6 +726,44 @@ fn mutation_contract(
}
}
fn read_only_surface_contract(
document_type: impl Into<String>,
payload_schema_version: impl Into<String>,
notes: Vec<&str>,
) -> CultNetDocumentMutationContract {
mutation_contract(
document_type,
payload_schema_version,
vec![CultNetDocumentOperation::Snapshot],
CultNetMutationAuthority::ReadOnly,
vec![],
vec![],
notes,
)
}
fn coordinator_surface_contract(
document_type: impl Into<String>,
payload_schema_version: impl Into<String>,
intent_document_types: Vec<&str>,
receipt_document_types: Vec<&str>,
notes: Vec<&str>,
) -> CultNetDocumentMutationContract {
mutation_contract(
document_type,
payload_schema_version,
vec![
CultNetDocumentOperation::Snapshot,
CultNetDocumentOperation::IntentSubmit,
CultNetDocumentOperation::ReceiptWatch,
],
CultNetMutationAuthority::Coordinator,
intent_document_types,
receipt_document_types,
notes,
)
}
fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
vec![
mutation_contract(
@ -798,6 +867,193 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
"The ledger is inspected as durable memory; writes are mediated by role-specific state flows.",
],
),
read_only_surface_contract(
SURFACE_SCENE_TYPE,
SCENE_SURFACE_SCHEMA_VERSION,
vec![
"Operator-safe scene reflection mirrored from thread/epiphany/scene.",
"Aquarium should read this before offering live coordination actions.",
],
),
read_only_surface_contract(
SURFACE_PRESSURE_TYPE,
PRESSURE_SURFACE_SCHEMA_VERSION,
vec![
"Current context pressure and compaction posture mirrored from thread/epiphany/pressure.",
"This is a read-only warning surface, not a backdoor to force state mutation.",
],
),
coordinator_surface_contract(
SURFACE_REORIENT_TYPE,
REORIENT_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.reorient_launch_intent.v0",
"epiphany.reorient_accept_intent.v0",
],
vec![
"epiphany.swarm_control_receipt.v0",
"epiphany.reorient_result_surface.v0",
],
vec![
"Reorientation policy is mirrored from thread/epiphany/reorient.",
"Launch and acceptance stay review-gated through explicit typed intents.",
],
),
read_only_surface_contract(
SURFACE_CRRC_TYPE,
CRRC_SURFACE_SCHEMA_VERSION,
vec![
"CRRC recommendation surface mirrored from thread/epiphany/crrc.",
"Use this to understand continuity pressure without letting CRRC seize authority.",
],
),
coordinator_surface_contract(
SURFACE_JOBS_TYPE,
JOBS_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.job_launch_intent.v0",
"epiphany.job_interrupt_intent.v0",
],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Job reflection and launch/interrupt affordances mirrored from thread/epiphany/jobs, jobLaunch, and jobInterrupt.",
"Heartbeat/runtime-spine owns activation; callers submit typed intents and watch receipts.",
],
),
coordinator_surface_contract(
SURFACE_ROLES_TYPE,
ROLES_SURFACE_SCHEMA_VERSION,
vec!["epiphany.role_launch_intent.v0"],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Role ownership and launch affordances mirrored from thread/epiphany/roles and roleLaunch.",
"Treat this as the discoverable lane catalog for Aquarium.",
],
),
coordinator_surface_contract(
SURFACE_ROLE_RESULT_TYPE,
ROLE_RESULT_SURFACE_SCHEMA_VERSION,
vec!["epiphany.role_accept_intent.v0"],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Role findings are read through thread/epiphany/roleResult and accepted through roleAccept.",
"Semantic findings remain explicitly review-gated.",
],
),
coordinator_surface_contract(
SURFACE_REORIENT_RESULT_TYPE,
REORIENT_RESULT_SURFACE_SCHEMA_VERSION,
vec!["epiphany.reorient_accept_intent.v0"],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Completed reorientation findings are read through thread/epiphany/reorientResult and accepted through reorientAccept.",
],
),
coordinator_surface_contract(
SURFACE_PLANNING_TYPE,
PLANNING_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.planning_update_intent.v0",
"epiphany.objective_adoption_intent.v0",
],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Planning projection is mirrored from thread/epiphany/planning.",
"Backlog, captures, and Objective Drafts are planning state until explicit adoption.",
],
),
read_only_surface_contract(
SURFACE_COORDINATOR_TYPE,
COORDINATOR_SURFACE_SCHEMA_VERSION,
vec![
"Fixed-lane recommendation surface mirrored from thread/epiphany/coordinator.",
"Aquarium should treat this as the primary action oracle, not invent its own scheduler.",
],
),
coordinator_surface_contract(
SURFACE_FACE_TYPE,
FACE_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.face_bubble_intent.v0",
"epiphany.character_turn_intent.v0",
"epiphany.discord_persona_post_intent.v0",
],
vec![
"epiphany.face_bubble.v0",
"epiphany.face_chat.v0",
"epiphany.character_turn_packet.v0",
],
vec![
"Face bubble, draft, and Discord persona affordances are mirrored from epiphany-face-discord and epiphany-character-loop.",
"Humans talk to Face; sealed inner thoughts stay behind the projection boundary.",
],
),
read_only_surface_contract(
SURFACE_VOID_MEMORY_TYPE,
VOID_MEMORY_SURFACE_SCHEMA_VERSION,
vec![
"Void-derived memory status/search/context availability is mirrored from epiphany-void-memory.",
"This is an inspection surface for the memory organs, not a license to bypass typed Epiphany state.",
],
),
coordinator_surface_contract(
SURFACE_REPO_INITIALIZATION_TYPE,
REPO_INITIALIZATION_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.repo_startup_intent.v0",
"epiphany.repo_initialization_accept_intent.v0",
],
vec![
"epiphany.repo_personality_artifacts.v0",
"epiphany.repo_initialization_record.v0",
],
vec![
"Repo birth/startup status is mirrored from epiphany-repo-personality startup and accept-init.",
"Birth specialists are startup-only and remain outside the heartbeat lane system.",
],
),
coordinator_surface_contract(
SURFACE_REPO_BIRTH_RUNNER_TYPE,
REPO_BIRTH_RUNNER_SURFACE_SCHEMA_VERSION,
vec!["epiphany.repo_birth_run_intent.v0"],
vec![
"epiphany.repo_birth_runner.v0",
"epiphany.repo_initialization_record.v0",
],
vec![
"Startup-only birth runner plan/run affordances are mirrored from epiphany-repo-birth-runner.",
"Aquarium should review birth artifacts and accept them explicitly instead of growing a hidden wizard.",
],
),
coordinator_surface_contract(
SURFACE_RIDER_BRIDGE_TYPE,
RIDER_BRIDGE_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.rider_status_intent.v0",
"epiphany.rider_context_intent.v0",
"epiphany.rider_open_ref_intent.v0",
],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Rider bridge affordances are mirrored from epiphany-rider-bridge status/context/open-ref.",
"Use this surface for source/IDE inspection instead of scraping local artifacts by convention.",
],
),
coordinator_surface_contract(
SURFACE_UNITY_BRIDGE_TYPE,
UNITY_BRIDGE_SURFACE_SCHEMA_VERSION,
vec![
"epiphany.unity_inspect_intent.v0",
"epiphany.unity_probe_intent.v0",
"epiphany.unity_check_compilation_intent.v0",
"epiphany.unity_run_tests_intent.v0",
],
vec!["epiphany.swarm_control_receipt.v0"],
vec![
"Unity bridge affordances are mirrored from epiphany-unity-bridge inspect/probe/check-compilation/run-tests.",
"Runtime/editor truth must come through the pinned bridge and its receipts, not wishful source reading.",
],
),
]
}
@ -990,6 +1246,45 @@ mod tests {
.operations
.contains(&CultNetDocumentOperation::IntentSubmit)
);
let coordinator_contract = contracts
.iter()
.find(|contract| contract.document_type == SURFACE_COORDINATOR_TYPE)
.expect("coordinator surface should advertise a read-only contract");
assert_eq!(
coordinator_contract.authority,
CultNetMutationAuthority::ReadOnly
);
let face_contract = contracts
.iter()
.find(|contract| contract.document_type == SURFACE_FACE_TYPE)
.expect("face surface should advertise an interactive contract");
assert_eq!(face_contract.authority, CultNetMutationAuthority::Coordinator);
assert!(
face_contract
.receipt_document_types
.as_ref()
.is_some_and(|items| items.iter().any(|item| item == "epiphany.face_bubble.v0"))
);
let unity_contract = contracts
.iter()
.find(|contract| contract.document_type == SURFACE_UNITY_BRIDGE_TYPE)
.expect("unity bridge surface should advertise an interactive contract");
assert!(
unity_contract
.intent_document_types
.as_ref()
.is_some_and(|items| items.iter().any(|item| item == "epiphany.unity_probe_intent.v0"))
);
let birth_contract = contracts
.iter()
.find(|contract| contract.document_type == SURFACE_REPO_BIRTH_RUNNER_TYPE)
.expect("repo birth runner surface should advertise startup actions");
assert!(
birth_contract
.receipt_document_types
.as_ref()
.is_some_and(|items| items.iter().any(|item| item == "epiphany.repo_birth_runner.v0"))
);
}
other => panic!("expected hello, got {other:?}"),
}