diff --git a/epiphany-core/src/admitted_model_direction_consideration.rs b/epiphany-core/src/admitted_model_direction_consideration.rs index 0569db53..81517375 100644 --- a/epiphany-core/src/admitted_model_direction_consideration.rs +++ b/epiphany-core/src/admitted_model_direction_consideration.rs @@ -98,10 +98,6 @@ pub fn commit_request( let identity = cache .get::(crate::RUNTIME_IDENTITY_KEY)? .ok_or_else(|| anyhow!("model direction consideration requires runtime identity"))?; - let Some(thread) = cache.get::(crate::THREAD_STATE_KEY)? - else { - return Ok(None); - }; let model = crate::assemble_repo_model_view(runtime_store)?; let model_basis = model.reasoning_basis(); let mut terminal = cache @@ -126,7 +122,7 @@ pub fn commit_request( schema_version: REQUEST_SCHEMA.into(), request_id: request_id.clone(), runtime_id: identity.runtime_id, - thread_id: thread.thread_id, + thread_id: request_id.clone(), model_projection_digest: model_basis.projection_digest, model_source_documents: model_basis.source_documents, previous_terminal_result_id, @@ -241,7 +237,6 @@ pub fn render_prompt(request: &AdmittedModelDirectionConsiderationRequest) -> St mod tests { use super::*; use sha2::{Digest, Sha256}; - use std::collections::BTreeMap; fn model_basis() -> crate::EpiphanyRepoModelBasis { let source_documents = vec![crate::EpiphanyMindDocumentVersion { @@ -346,32 +341,33 @@ mod tests { } #[test] - fn cold_runtime_without_thread_has_no_direction_request_yet() -> Result<()> { + fn keyed_repo_model_without_thread_creates_direction_request() -> Result<()> { let temp = tempfile::tempdir()?; let store = temp.path().join("runtime.cc"); - let mut cache = crate::runtime_spine_cache(&store)?; - cache.put( - crate::RUNTIME_IDENTITY_KEY, - &crate::EpiphanyRuntimeIdentity { - schema_version: crate::RUNTIME_SPINE_SCHEMA_VERSION.into(), + crate::initialize_runtime_spine( + &store, + crate::RuntimeSpineInitOptions { runtime_id: "runtime-cold".into(), display_name: "Cold runtime".into(), - runtime_kind: "resident".into(), created_at: "2026-07-18T00:00:00Z".into(), - updated_at: "2026-07-18T00:00:00Z".into(), - supported_document_types: Vec::new(), - metadata: BTreeMap::new(), + }, + )?; + let mut cache = crate::runtime_spine_cache(&store)?; + cache.put( + crate::REPO_MODEL_IDENTITY_KEY, + &crate::EpiphanyRepoModelIdentityDocument { + schema_epoch: crate::REPO_MODEL_SCHEMA_EPOCH.into(), + graph_id: "graph-cold".into(), + runtime_id: "runtime-cold".into(), + swarm_id: "swarm-cold".into(), + workspace_id: "workspace-cold".into(), + body_binding_sha256: "sha256:body-cold".into(), }, )?; - assert!(commit_request(&store, "2026-07-18T00:01:00Z")?.is_none()); - let mut reloaded = crate::runtime_spine_cache(&store)?; - reloaded.pull_all_backing_stores()?; - assert!( - reloaded - .get_all::()? - .is_empty() - ); + let request = commit_request(&store, "2026-07-18T00:01:00Z")? + .ok_or_else(|| anyhow!("keyed RepoModel should create direction work"))?; + assert_eq!(request.thread_id, request.request_id); Ok(()) } } diff --git a/epiphany-core/src/imagination_consideration.rs b/epiphany-core/src/imagination_consideration.rs index a20a3469..2f303540 100644 --- a/epiphany-core/src/imagination_consideration.rs +++ b/epiphany-core/src/imagination_consideration.rs @@ -211,10 +211,6 @@ pub fn commit_request( let identity = cache .get::(crate::RUNTIME_IDENTITY_KEY)? .ok_or_else(|| anyhow!("consideration requires runtime identity"))?; - let Some(thread) = cache.get::(crate::THREAD_STATE_KEY)? - else { - return Ok(None); - }; let model_basis = crate::assemble_repo_model_view(runtime_store)?.reasoning_basis(); let feedback = crate::admitted_persona_feedback(persona_feedback_store, &identity.runtime_id)? .into_iter() @@ -242,7 +238,7 @@ pub fn commit_request( data_classification: feedback.data_classification.clone(), source_provider_identity_id: feedback.bifrost_provider_identity_id, runtime_id: identity.runtime_id, - thread_id: thread.thread_id, + thread_id: request_id.clone(), repository: repository.into(), persona_id: persona_id.into(), model_projection_digest: model_basis.projection_digest, @@ -460,39 +456,73 @@ pub fn request_candidate_modeling_review( #[cfg(test)] mod tests { use super::*; - use std::collections::BTreeMap; #[test] - fn cold_runtime_without_thread_defers_feedback_consideration() -> Result<()> { + fn keyed_feedback_and_repo_model_without_thread_create_consideration() -> Result<()> { let temp = tempfile::tempdir()?; let runtime = temp.path().join("runtime.cc"); let feedback = temp.path().join("feedback.cc"); - let mut cache = crate::runtime_spine_cache(&runtime)?; - cache.put( - crate::RUNTIME_IDENTITY_KEY, - &crate::EpiphanyRuntimeIdentity { - schema_version: crate::RUNTIME_SPINE_SCHEMA_VERSION.into(), + crate::initialize_runtime_spine( + &runtime, + crate::RuntimeSpineInitOptions { runtime_id: "runtime-cold".into(), display_name: "Cold runtime".into(), - runtime_kind: "resident".into(), created_at: "2026-07-18T00:00:00Z".into(), - updated_at: "2026-07-18T00:00:00Z".into(), - supported_document_types: Vec::new(), - metadata: BTreeMap::new(), }, )?; - assert!( - commit_request( - &runtime, - &feedback, - "feedback-1", - "GameCult/Epiphany", - "epiphany", - "resident-feedback-consideration-v0", - "2026-07-18T00:01:00Z", - )? - .is_none() - ); + let mut cache = crate::runtime_spine_cache(&runtime)?; + cache.put( + crate::REPO_MODEL_IDENTITY_KEY, + &crate::EpiphanyRepoModelIdentityDocument { + schema_epoch: crate::REPO_MODEL_SCHEMA_EPOCH.into(), + graph_id: "graph-cold".into(), + runtime_id: "runtime-cold".into(), + swarm_id: "swarm-cold".into(), + workspace_id: "workspace-cold".into(), + body_binding_sha256: "sha256:body-cold".into(), + }, + )?; + let admitted = crate::LocalAdmittedPersonaFeedback { + schema_version: crate::LOCAL_PERSONA_FEEDBACK_SCHEMA_VERSION.into(), + feedback_id: "feedback-1".into(), + admission_id: "admission-1".into(), + source_actor_id: "actor-1".into(), + source_provider: "bifrost".into(), + target_runtime_id: "runtime-cold".into(), + target_repository: "GameCult/Epiphany".into(), + target_persona_id: "epiphany".into(), + source_room_id: "discord://room-1".into(), + feedback_text: "Inspect the keyed Mind.".into(), + source_discussion_refs: vec!["discord://message-1".into()], + bifrost_provider_identity_id: "bifrost-1".into(), + authority: "resident-pressure-only".into(), + private_state_exposed: false, + source_visibility: "organization".into(), + data_classification: "organization_feedback".into(), + packet_sha256: "sha256-feedback".into(), + source_observer_id: "bifrost-discord".into(), + source_observer_runtime_id: "bifrost-runtime".into(), + source_event_id: "event-1".into(), + discord_guild_id: "guild-1".into(), + discord_channel_id: "channel-1".into(), + discord_message_id: "message-1".into(), + }; + let mut feedback_cache = cultcache_rs::CultCache::new(); + feedback_cache.register_entry_type::()?; + let (entry, _) = feedback_cache.prepare_entry(&admitted.feedback_id, &admitted)?; + assert!(SingleFileMessagePackBackingStore::new(&feedback).insert_entry_if_absent(entry)?); + + let request = commit_request( + &runtime, + &feedback, + "feedback-1", + "GameCult/Epiphany", + "epiphany", + "resident-feedback-consideration-v0", + "2026-07-18T00:01:00Z", + )? + .ok_or_else(|| anyhow!("admitted feedback should create consideration work"))?; + assert_eq!(request.thread_id, request.request_id); Ok(()) } diff --git a/epiphany-core/src/reorientation_work.rs b/epiphany-core/src/reorientation_work.rs index b89e1689..e54b35ec 100644 --- a/epiphany-core/src/reorientation_work.rs +++ b/epiphany-core/src/reorientation_work.rs @@ -860,7 +860,10 @@ mod tests { (agent_launch, "build_epiphany_reorient_launch_request"), (worker_launch, "EpiphanyReorientLaunchRequestInput"), ] { - assert!(!source.contains(forbidden), "obsolete reorientation authority {forbidden:?} survived"); + assert!( + !source.contains(forbidden), + "obsolete reorientation authority {forbidden:?} survived" + ); } } diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 81b7bbcb..12532feb 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -6021,12 +6021,6 @@ pub fn promote_autonomous_direction_options_for_modeling( let mut opening = runtime_spine_cache(runtime_store)?; opening.pull_all_backing_stores()?; let identity = require_identity(&opening)?; - if opening - .get::(crate::THREAD_STATE_KEY)? - .is_none() - { - return Ok(Vec::new()); - } if opening .get::(crate::REPO_MODEL_IDENTITY_KEY)? .is_none() @@ -6265,9 +6259,6 @@ pub fn promote_autonomous_direction_options_for_modeling( current .get_envelope::(RUNTIME_IDENTITY_KEY)? .ok_or_else(|| anyhow!("runtime identity envelope disappeared"))?, - current - .get_envelope::(crate::THREAD_STATE_KEY)? - .ok_or_else(|| anyhow!("thread envelope disappeared"))?, current .get_envelope::( crate::RUNTIME_BODY_STORE_BINDING_KEY,