Bind model executions to runtime sessions
This commit is contained in:
parent
34d4937cac
commit
2d817522ce
8 changed files with 497 additions and 16 deletions
|
|
@ -984,6 +984,7 @@ pub use runtime_spine::EpiphanyRuntimeJob;
|
|||
pub use runtime_spine::EpiphanyRuntimeJobResult;
|
||||
pub use runtime_spine::EpiphanyRuntimeJobSnapshot;
|
||||
pub use runtime_spine::EpiphanyRuntimeJobStatus;
|
||||
pub use runtime_spine::EpiphanyRuntimeModelExecutionBinding;
|
||||
pub use runtime_spine::EpiphanyRuntimeReorientWorkerResult;
|
||||
pub use runtime_spine::EpiphanyRuntimeRoleWorkerResult;
|
||||
pub use runtime_spine::EpiphanyRuntimeSession;
|
||||
|
|
@ -998,6 +999,8 @@ pub use runtime_spine::RUNTIME_IDENTITY_KEY;
|
|||
pub use runtime_spine::RUNTIME_IDENTITY_TYPE;
|
||||
pub use runtime_spine::RUNTIME_JOB_RESULT_TYPE;
|
||||
pub use runtime_spine::RUNTIME_JOB_TYPE;
|
||||
pub use runtime_spine::RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION;
|
||||
pub use runtime_spine::RUNTIME_MODEL_EXECUTION_BINDING_TYPE;
|
||||
pub use runtime_spine::RUNTIME_REORIENT_WORKER_RESULT_SCHEMA_VERSION;
|
||||
pub use runtime_spine::RUNTIME_REORIENT_WORKER_RESULT_TYPE;
|
||||
pub use runtime_spine::RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION;
|
||||
|
|
@ -1069,6 +1072,7 @@ pub use runtime_spine::put_repo_frontier_verification_request;
|
|||
pub use runtime_spine::put_repo_frontier_work_proposal;
|
||||
pub use runtime_spine::put_runtime_reorient_worker_result;
|
||||
pub use runtime_spine::put_runtime_role_worker_result;
|
||||
pub use runtime_spine::open_runtime_model_execution;
|
||||
pub use runtime_spine::put_soul_verdict_receipt;
|
||||
pub use runtime_spine::put_substrate_gate_repo_access_grant_receipt;
|
||||
pub use runtime_spine::relinquish_repo_frontier_hands_route;
|
||||
|
|
|
|||
|
|
@ -158,6 +158,8 @@ use std::path::PathBuf;
|
|||
pub const RUNTIME_IDENTITY_TYPE: &str = "epiphany.runtime.identity";
|
||||
pub const RUNTIME_SESSION_TYPE: &str = "epiphany.runtime.session";
|
||||
pub const RUNTIME_JOB_TYPE: &str = "epiphany.runtime.job";
|
||||
pub const RUNTIME_MODEL_EXECUTION_BINDING_TYPE: &str =
|
||||
"epiphany.runtime.model_execution_binding";
|
||||
pub const RUNTIME_WORKER_LAUNCH_REQUEST_TYPE: &str = "epiphany.runtime.worker_launch_request";
|
||||
pub const RUNTIME_ROLE_WORKER_RESULT_TYPE: &str = "epiphany.runtime.role_worker_result";
|
||||
pub const RUNTIME_REORIENT_WORKER_RESULT_TYPE: &str = "epiphany.runtime.reorient_worker_result";
|
||||
|
|
@ -183,6 +185,8 @@ pub const RUNTIME_SWARM_BINDING_TYPE: &str = "epiphany.runtime.swarm_binding";
|
|||
pub const RUNTIME_SWARM_BINDING_KEY: &str = "runtime-swarm-binding";
|
||||
pub const RUNTIME_SWARM_BINDING_SCHEMA_VERSION: &str = "epiphany.runtime.swarm_binding.v0";
|
||||
pub const RUNTIME_SPINE_SCHEMA_VERSION: &str = "epiphany.runtime_spine.v0";
|
||||
pub const RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.model_execution_binding.v0";
|
||||
pub const RUNTIME_WORKER_LAUNCH_REQUEST_SCHEMA_VERSION: &str =
|
||||
"epiphany.runtime.worker_launch_request.v1";
|
||||
pub const RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION: &str =
|
||||
|
|
@ -317,6 +321,28 @@ pub struct EpiphanyRuntimeJob {
|
|||
pub metadata: BTreeMap<String, String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.runtime.model_execution_binding",
|
||||
schema = "EpiphanyRuntimeModelExecutionBinding"
|
||||
)]
|
||||
pub struct EpiphanyRuntimeModelExecutionBinding {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub binding_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub request_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub session_id: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub job_id: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub provider: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub bound_at: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.runtime.worker_launch_request",
|
||||
|
|
@ -949,6 +975,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
cache.register_entry_type::<crate::MemorySemanticProjectorRecoveryAuthorization>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeSession>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeJob>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeModelExecutionBinding>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeWorkerLaunchRequest>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeRoleWorkerResult>()?;
|
||||
cache.register_entry_type::<crate::EpiphanyMemoryGraphEntry>()?;
|
||||
|
|
@ -1386,6 +1413,163 @@ pub fn create_runtime_job(
|
|||
Ok(job)
|
||||
}
|
||||
|
||||
pub fn open_runtime_model_execution(
|
||||
store_path: impl AsRef<Path>,
|
||||
session_options: RuntimeSpineSessionOptions,
|
||||
job_options: RuntimeSpineJobOptions,
|
||||
model_request: &EpiphanyModelRequest,
|
||||
provider_request: &EpiphanyOpenAiModelRequest,
|
||||
bound_at: &str,
|
||||
) -> Result<EpiphanyRuntimeModelExecutionBinding> {
|
||||
validate_non_empty(&session_options.session_id, "model execution session id")?;
|
||||
validate_non_empty(&session_options.objective, "model execution objective")?;
|
||||
validate_non_empty(&session_options.created_at, "model execution session creation time")?;
|
||||
validate_non_empty(&job_options.job_id, "model execution job id")?;
|
||||
validate_non_empty(&job_options.role, "model execution job role")?;
|
||||
validate_non_empty(&job_options.created_at, "model execution job creation time")?;
|
||||
if job_options.session_id != session_options.session_id {
|
||||
return Err(anyhow!(
|
||||
"model execution job and session options disagree on session identity"
|
||||
));
|
||||
}
|
||||
validate_non_empty(&model_request.request_id, "model execution request id")?;
|
||||
validate_non_empty(&model_request.provider, "model execution provider")?;
|
||||
validate_non_empty(bound_at, "model execution binding time")?;
|
||||
chrono::DateTime::parse_from_rfc3339(bound_at)
|
||||
.map_err(|error| anyhow!("model execution binding time is invalid: {error}"))?;
|
||||
if provider_request.request_id != model_request.request_id
|
||||
|| provider_request.conversation_id != model_request.conversation_id
|
||||
|| provider_request.model != model_request.model
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"native and provider model requests do not describe one execution"
|
||||
));
|
||||
}
|
||||
|
||||
let store_path = store_path.as_ref();
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
let existing_session = cache.get::<EpiphanyRuntimeSession>(&session_options.session_id)?;
|
||||
let session = existing_session.clone().unwrap_or_else(|| EpiphanyRuntimeSession {
|
||||
schema_version: RUNTIME_SPINE_SCHEMA_VERSION.to_string(),
|
||||
session_id: session_options.session_id.clone(),
|
||||
objective: session_options.objective.clone(),
|
||||
status: EpiphanyRuntimeSessionStatus::Active,
|
||||
created_at: session_options.created_at.clone(),
|
||||
updated_at: session_options.created_at.clone(),
|
||||
coordinator_note: session_options.coordinator_note.clone(),
|
||||
metadata: BTreeMap::new(),
|
||||
});
|
||||
if matches!(
|
||||
session.status,
|
||||
EpiphanyRuntimeSessionStatus::Completed | EpiphanyRuntimeSessionStatus::Archived
|
||||
) {
|
||||
return Err(anyhow!(
|
||||
"model execution session {:?} is terminal",
|
||||
session.session_id
|
||||
));
|
||||
}
|
||||
if cache.get::<EpiphanyRuntimeJob>(&job_options.job_id)?.is_some() {
|
||||
return Err(anyhow!(
|
||||
"model execution job {:?} already exists",
|
||||
job_options.job_id
|
||||
));
|
||||
}
|
||||
let job = EpiphanyRuntimeJob {
|
||||
schema_version: RUNTIME_SPINE_SCHEMA_VERSION.to_string(),
|
||||
job_id: job_options.job_id.clone(),
|
||||
session_id: session.session_id.clone(),
|
||||
role: job_options.role,
|
||||
status: EpiphanyRuntimeJobStatus::Queued,
|
||||
created_at: job_options.created_at.clone(),
|
||||
updated_at: job_options.created_at.clone(),
|
||||
summary: job_options.summary,
|
||||
artifact_refs: job_options.artifact_refs,
|
||||
metadata: BTreeMap::new(),
|
||||
};
|
||||
let opened_event = EpiphanyRuntimeEvent {
|
||||
schema_version: RUNTIME_SPINE_SCHEMA_VERSION.to_string(),
|
||||
event_id: format!("event-job-opened-{}", job.job_id),
|
||||
occurred_at: job_options.created_at,
|
||||
event_type: "job.opened".to_string(),
|
||||
source: "runtime-spine".to_string(),
|
||||
session_id: Some(session.session_id.clone()),
|
||||
job_id: Some(job.job_id.clone()),
|
||||
summary: "Native runtime job opened.".to_string(),
|
||||
metadata: BTreeMap::new(),
|
||||
};
|
||||
if cache
|
||||
.get::<EpiphanyRuntimeEvent>(&opened_event.event_id)?
|
||||
.is_some()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"model execution opened event {:?} already exists",
|
||||
opened_event.event_id
|
||||
));
|
||||
}
|
||||
|
||||
let binding_id = model_request.request_id.clone();
|
||||
if cache
|
||||
.get::<EpiphanyRuntimeModelExecutionBinding>(&binding_id)?
|
||||
.is_some()
|
||||
|| cache
|
||||
.get::<EpiphanyModelRequest>(&model_request.request_id)?
|
||||
.is_some()
|
||||
|| cache
|
||||
.get::<EpiphanyOpenAiModelRequest>(&provider_request.request_id)?
|
||||
.is_some()
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"model execution request {:?} already exists",
|
||||
model_request.request_id
|
||||
));
|
||||
}
|
||||
let binding = EpiphanyRuntimeModelExecutionBinding {
|
||||
schema_version: RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION.to_string(),
|
||||
binding_id: binding_id.clone(),
|
||||
request_id: model_request.request_id.clone(),
|
||||
session_id: session.session_id.clone(),
|
||||
job_id: job.job_id.clone(),
|
||||
provider: model_request.provider.clone(),
|
||||
bound_at: bound_at.to_string(),
|
||||
};
|
||||
let identity_envelope = cache
|
||||
.get_envelope::<EpiphanyRuntimeIdentity>(RUNTIME_IDENTITY_KEY)?
|
||||
.ok_or_else(|| anyhow!("model execution lost its exact runtime identity envelope"))?;
|
||||
let mut expected = vec![identity_envelope.clone()];
|
||||
if existing_session.is_some() {
|
||||
expected.push(
|
||||
cache
|
||||
.get_envelope::<EpiphanyRuntimeSession>(&session.session_id)?
|
||||
.ok_or_else(|| anyhow!("model execution lost its exact session envelope"))?,
|
||||
);
|
||||
}
|
||||
let replacements = vec![
|
||||
identity_envelope,
|
||||
cache.prepare_entry(&session.session_id, &session)?.0,
|
||||
cache.prepare_entry(&job.job_id, &job)?.0,
|
||||
cache
|
||||
.prepare_entry(&opened_event.event_id, &opened_event)?
|
||||
.0,
|
||||
cache.prepare_entry(&binding_id, &binding)?.0,
|
||||
cache
|
||||
.prepare_entry(&model_request.request_id, model_request)?
|
||||
.0,
|
||||
cache
|
||||
.prepare_entry(&provider_request.request_id, provider_request)?
|
||||
.0,
|
||||
];
|
||||
if !runtime_spine_backing_store(store_path)?
|
||||
.compare_and_swap_batch(&expected, replacements)?
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"model execution request publication lost its snapshot fence"
|
||||
));
|
||||
}
|
||||
Ok(binding)
|
||||
}
|
||||
|
||||
pub fn plan_runtime_spine_heartbeat_launch(
|
||||
state: &EpiphanyThreadState,
|
||||
options: RuntimeSpineHeartbeatLaunchPlanOptions,
|
||||
|
|
@ -9983,6 +10167,18 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
|
|||
"Coordinator run receipts are typed summaries of local plan/run decisions; artifact JSON is display evidence, not the only durable account.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
RUNTIME_MODEL_EXECUTION_BINDING_TYPE,
|
||||
RUNTIME_MODEL_EXECUTION_BINDING_SCHEMA_VERSION,
|
||||
vec![CultNetDocumentOperation::Snapshot],
|
||||
CultNetMutationAuthority::ReadOnly,
|
||||
vec![],
|
||||
vec![],
|
||||
vec![
|
||||
"Runtime spine atomically binds one native/provider model request pair to its owning session and job before transport begins.",
|
||||
"Retention must reject unbound model rows rather than infer ownership from request names or conversation ids.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
MODEL_ADAPTER_STATUS_TYPE,
|
||||
MODEL_ADAPTER_STATUS_SCHEMA_VERSION,
|
||||
|
|
@ -14341,6 +14537,136 @@ pub(crate) mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_model_execution_binding_owns_atomic_request_membership() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
&store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-test".to_string(),
|
||||
display_name: "Epiphany Test".to_string(),
|
||||
created_at: "2026-08-10T00:00:00Z".to_string(),
|
||||
},
|
||||
)?;
|
||||
let session_options = RuntimeSpineSessionOptions {
|
||||
session_id: "session-model".to_string(),
|
||||
objective: "Own model execution membership.".to_string(),
|
||||
created_at: "2026-08-10T00:00:01Z".to_string(),
|
||||
coordinator_note: "test".to_string(),
|
||||
};
|
||||
let job_options = RuntimeSpineJobOptions {
|
||||
job_id: "job-model".to_string(),
|
||||
session_id: "session-model".to_string(),
|
||||
role: "openai-model-adapter".to_string(),
|
||||
created_at: "2026-08-10T00:00:02Z".to_string(),
|
||||
summary: "Bound model execution.".to_string(),
|
||||
artifact_refs: Vec::new(),
|
||||
};
|
||||
let model_request = EpiphanyModelRequest::new(
|
||||
"request-model",
|
||||
"conversation-model",
|
||||
"openai-codex",
|
||||
"gpt-test",
|
||||
"Return typed evidence.",
|
||||
);
|
||||
let provider_request = EpiphanyOpenAiModelRequest::new(
|
||||
"request-model",
|
||||
"conversation-model",
|
||||
"gpt-test",
|
||||
"Return typed evidence.",
|
||||
);
|
||||
let binding = open_runtime_model_execution(
|
||||
&store,
|
||||
session_options.clone(),
|
||||
job_options.clone(),
|
||||
&model_request,
|
||||
&provider_request,
|
||||
"2026-08-10T00:00:03Z",
|
||||
)?;
|
||||
assert_eq!(binding.request_id, "request-model");
|
||||
assert_eq!(binding.session_id, "session-model");
|
||||
assert_eq!(binding.job_id, "job-model");
|
||||
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyRuntimeModelExecutionBinding>("request-model")?,
|
||||
Some(binding)
|
||||
);
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyModelRequest>("request-model")?,
|
||||
Some(model_request.clone())
|
||||
);
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyOpenAiModelRequest>("request-model")?,
|
||||
Some(provider_request.clone())
|
||||
);
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyRuntimeSession>("session-model")?.unwrap().status,
|
||||
EpiphanyRuntimeSessionStatus::Active
|
||||
);
|
||||
assert_eq!(
|
||||
cache.get::<EpiphanyRuntimeJob>("job-model")?.unwrap().status,
|
||||
EpiphanyRuntimeJobStatus::Queued
|
||||
);
|
||||
assert!(cache
|
||||
.get::<EpiphanyRuntimeEvent>("event-job-opened-job-model")?
|
||||
.is_some());
|
||||
assert!(open_runtime_model_execution(
|
||||
&store,
|
||||
session_options.clone(),
|
||||
job_options.clone(),
|
||||
&model_request,
|
||||
&provider_request,
|
||||
"2026-08-10T00:00:04Z",
|
||||
)
|
||||
.is_err());
|
||||
|
||||
let foreign_provider = EpiphanyOpenAiModelRequest::new(
|
||||
"request-foreign",
|
||||
"conversation-foreign",
|
||||
"gpt-other",
|
||||
"Return typed evidence.",
|
||||
);
|
||||
let foreign_model = EpiphanyModelRequest::new(
|
||||
"request-foreign",
|
||||
"conversation-foreign",
|
||||
"openai-codex",
|
||||
"gpt-test",
|
||||
"Return typed evidence.",
|
||||
);
|
||||
let mut foreign_job_options = job_options;
|
||||
foreign_job_options.job_id = "job-foreign".to_string();
|
||||
assert!(open_runtime_model_execution(
|
||||
&store,
|
||||
session_options,
|
||||
foreign_job_options,
|
||||
&foreign_model,
|
||||
&foreign_provider,
|
||||
"2026-08-10T00:00:05Z",
|
||||
)
|
||||
.is_err());
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
assert!(cache
|
||||
.get::<EpiphanyRuntimeModelExecutionBinding>("request-foreign")?
|
||||
.is_none());
|
||||
assert!(cache
|
||||
.get::<EpiphanyModelRequest>("request-foreign")?
|
||||
.is_none());
|
||||
assert!(cache
|
||||
.get::<EpiphanyOpenAiModelRequest>("request-foreign")?
|
||||
.is_none());
|
||||
assert!(cache
|
||||
.get::<EpiphanyRuntimeJob>("job-foreign")?
|
||||
.is_none());
|
||||
assert!(cache
|
||||
.get::<EpiphanyRuntimeEvent>("event-job-opened-job-foreign")?
|
||||
.is_none());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_spine_opens_and_completes_native_jobs() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use epiphany_core::ensure_runtime_session;
|
|||
use epiphany_core::initialize_runtime_spine;
|
||||
use epiphany_core::put_runtime_reorient_worker_result;
|
||||
use epiphany_core::put_runtime_role_worker_result;
|
||||
use epiphany_core::open_runtime_model_execution;
|
||||
use epiphany_core::runtime_spine_cache;
|
||||
use epiphany_core::runtime_spine_status;
|
||||
use epiphany_core::EpiphanyRuntimeReorientWorkerResult;
|
||||
|
|
@ -109,15 +110,19 @@ pub struct EpiphanyWorkerRuntimeRunSummary {
|
|||
pub async fn run_openai_model_turn(
|
||||
options: EpiphanyOpenAiRuntimeOptions,
|
||||
request: EpiphanyOpenAiModelRequest,
|
||||
) -> Result<EpiphanyOpenAiRuntimeRunSummary> {
|
||||
let model_request = model_request_from_openai_request(DEFAULT_MODEL_PROVIDER, &request);
|
||||
run_openai_model_turn_bound(options, model_request, request).await
|
||||
}
|
||||
|
||||
async fn run_openai_model_turn_bound(
|
||||
options: EpiphanyOpenAiRuntimeOptions,
|
||||
model_request: EpiphanyModelRequest,
|
||||
request: EpiphanyOpenAiModelRequest,
|
||||
) -> Result<EpiphanyOpenAiRuntimeRunSummary> {
|
||||
ensure_openai_runtime_ready(&options)?;
|
||||
let auth_manager = auth_manager(options.codex_home.clone());
|
||||
store_model_request(
|
||||
&options.store_path,
|
||||
&model_request_from_openai_request(DEFAULT_MODEL_PROVIDER, &request),
|
||||
)?;
|
||||
store_openai_request(&options.store_path, &request)?;
|
||||
ensure_runtime_session(
|
||||
open_runtime_model_execution(
|
||||
&options.store_path,
|
||||
RuntimeSpineSessionOptions {
|
||||
session_id: options.session_id.clone(),
|
||||
|
|
@ -125,9 +130,6 @@ pub async fn run_openai_model_turn(
|
|||
created_at: now(),
|
||||
coordinator_note: options.coordinator_note.clone(),
|
||||
},
|
||||
)?;
|
||||
create_runtime_job(
|
||||
&options.store_path,
|
||||
RuntimeSpineJobOptions {
|
||||
job_id: options.job_id.clone(),
|
||||
session_id: options.session_id.clone(),
|
||||
|
|
@ -136,6 +138,9 @@ pub async fn run_openai_model_turn(
|
|||
summary: format!("OpenAI model request {}", request.request_id),
|
||||
artifact_refs: Vec::new(),
|
||||
},
|
||||
&model_request,
|
||||
&request,
|
||||
&now(),
|
||||
)?;
|
||||
append_runtime_event(
|
||||
&options.store_path,
|
||||
|
|
@ -283,11 +288,8 @@ pub async fn run_model_turn(
|
|||
provider
|
||||
));
|
||||
}
|
||||
let store_path = options.store_path.clone();
|
||||
let summary =
|
||||
run_openai_model_turn(options, openai_request_from_model_request(&request)).await?;
|
||||
store_model_request(&store_path, &request)?;
|
||||
Ok(summary)
|
||||
let provider_request = openai_request_from_model_request(&request);
|
||||
run_openai_model_turn_bound(options, request, provider_request).await
|
||||
}
|
||||
|
||||
pub async fn run_tool_followup_model_turn(
|
||||
|
|
|
|||
|
|
@ -2304,6 +2304,105 @@ These are not one retention family merely because they share a file.
|
|||
must not be removed merely because a model receipt exists; tool follow-up and
|
||||
review/recovery readers must first be closed.
|
||||
|
||||
Source inspection after the accepted `6dd9b132` fulfillment run sharpens that
|
||||
boundary. `EpiphanyRuntimeSession` is currently a job-admission owner, not a
|
||||
complete storage generation. The runtime spine gives every job, generic job
|
||||
result, and runtime event an explicit `session_id`; worker launch requests and
|
||||
typed role/reorient results join through `job_id`; coordinator run receipts
|
||||
also carry `session_id`. Those families have a typed path back to one session.
|
||||
|
||||
The model/tool families do not yet share that path:
|
||||
|
||||
- Native and OpenAI model requests carry `conversation_id` and `request_id`,
|
||||
but no runtime session or job identity. Worker request IDs happen to contain
|
||||
a sanitized job ID and worker conversations happen to name a role binding;
|
||||
both are naming conventions, not retention authority.
|
||||
- Native and OpenAI stream events and model receipts join exactly to their
|
||||
request by `request_id`. A terminal event closes transport production, but
|
||||
the native model request remains live while tool follow-up may reload it.
|
||||
- Tool intents join to a model request only when they came from a model tool
|
||||
call. Tool receipts join exactly to an intent. Direct tool intents have no
|
||||
session/job owner at all.
|
||||
- Runtime events emitted by the OpenAI runner name the session and job, but do
|
||||
not authenticate which model request/event envelope they describe. Human
|
||||
summaries and key-shape conventions cannot be promoted into a deletion
|
||||
graph.
|
||||
- `EpiphanyRuntimeJobResult` may cite `openai-request:<id>` as an evidence ref,
|
||||
but this is an artifact/evidence string, not a typed immutable membership
|
||||
edge and is not present on every model execution path.
|
||||
|
||||
The semantic families in the same `.cc` file are not session exhaust. Repo
|
||||
model admissions, frontier requests/routes, Hands/Soul receipts, Persona
|
||||
effects, memory graph/projection state, and accepted typed worker results may
|
||||
remain current Mind or consequence authority after the process session closes.
|
||||
Physical co-location is not ownership. Runtime archive must therefore leave
|
||||
semantic documents byte-identical unless an owning semantic compactor proves
|
||||
its own replacement contract. Conversely, if a retained semantic document
|
||||
still resolves an execution request/result by ID, that exact execution
|
||||
envelope remains live and runtime archive must refuse it rather than leave an
|
||||
ID-shaped hole that a later row could impersonate.
|
||||
|
||||
The intended archive cut is now explicit:
|
||||
|
||||
- **Owner:** one runtime-spine `ArchivedRuntimeSession` tombstone owns permanent
|
||||
death of an exact completed session. Session status, operator counts, age,
|
||||
and a digest-only retention head are no longer archive owners.
|
||||
- **Inputs:** the exact completed session; only terminal session-local jobs;
|
||||
their typed job/launch/result/event closure; explicit model-execution
|
||||
bindings to session and job; terminal native/OpenAI request streams and
|
||||
receipts; fully receipted tool intents; coordinator receipts not live across
|
||||
resident state; and a full-store scan proving no retained semantic/runtime
|
||||
document references a member selected for retirement.
|
||||
- **Outputs:** one typed tombstone containing the session identity, terminal
|
||||
outcome/counts, exact retired-family counts, a chained digest of exact
|
||||
retired envelopes, and the retention timestamp; plus deletion of those exact
|
||||
envelopes in the same full-snapshot-fenced transaction.
|
||||
- **Derived state:** runtime history counts and old stream text are observation
|
||||
only after archival. The tombstone is evidence and an ID-reuse barrier; it
|
||||
cannot satisfy a job, model request, tool call, coordinator receipt, or
|
||||
semantic review.
|
||||
- **Forbidden writers:** model transport, tool runtime, coordinator receipt
|
||||
retention, resident lifecycle retention, semantic projection, wall-clock
|
||||
cleanup, and operator commands cannot mark a session archived or infer
|
||||
membership from prefixes, timestamps, summaries, conversation names, or
|
||||
evidence strings.
|
||||
- **Shared paths:** every native/OpenAI model execution must publish the same
|
||||
typed request-to-session/job binding at request creation; every model-derived
|
||||
and direct tool execution must publish an exact execution owner before an
|
||||
intent can become pending. Bounded and unbounded runners use the same write
|
||||
primitive. Legacy unbound rows are retained and make their candidate session
|
||||
ineligible; migration may add a binding only from independently authenticated
|
||||
typed evidence.
|
||||
- **Cut line:** first add the missing typed model/tool ownership edges and make
|
||||
request/intent creation atomic with them. Then add the archive tombstone and
|
||||
one snapshot-fenced replace/delete primitive. Do not begin with a generic
|
||||
age window, a key-prefix crawler, or a repair registry assembled after the
|
||||
fact.
|
||||
- **Negative verification:** an archived tombstone blocks recreation of its
|
||||
session; missing/duplicate/foreign bindings refuse archive; a nonterminal
|
||||
stream or unreceipted tool intent refuses archive; a retained semantic
|
||||
reference refuses deletion; stale snapshots refuse; unknown rows and live
|
||||
sessions remain byte-identical; the tombstone cannot resurrect work; and
|
||||
exact replay is idempotent.
|
||||
|
||||
The first ownership edge is now implemented. Runtime spine owns
|
||||
`EpiphanyRuntimeModelExecutionBinding` and one `open_runtime_model_execution`
|
||||
CAS. That transaction validates one native/provider request pair, preserves an
|
||||
exact runtime identity/session fence, and atomically publishes the session,
|
||||
queued job, deterministic opened event, immutable binding, and both request
|
||||
envelopes. The OpenAI runtime cannot begin transport before this succeeds.
|
||||
Collision, foreign request shape, concurrent session mutation, or terminal
|
||||
session state leaves no partial job/event/request family. Legacy standalone
|
||||
request writers remain available only as unbound compatibility surfaces; their
|
||||
rows are deliberately ineligible for archival. Core hostile membership tests,
|
||||
the CultNet Hello/catalog tests, and all 15 OpenAI runtime library tests pass.
|
||||
|
||||
Tool execution ownership is the next cut. Model-derived intents can inherit
|
||||
the exact model binding through `model_request_id`; direct intents need their
|
||||
own explicit session/job binding. Intent publication and its execution-owner
|
||||
edge must become one CAS before an archive tombstone or any broad deletion is
|
||||
implemented.
|
||||
|
||||
The coordinator receipt accumulator is implemented in source. Runtime owns the
|
||||
typed head, cumulative status counts, chained digest, and full-snapshot-fenced
|
||||
replacement/deletion. Resident Self supplies the cross-store preservation set
|
||||
|
|
|
|||
|
|
@ -1476,3 +1476,16 @@ model-request/result/stream-event, and tool-intent/receipt ownership and
|
|||
cross-store liveness before editing. No age-only deletion and no broad
|
||||
compaction are authorized until one typed archived-session owner can prove a
|
||||
fully closed, unreferenced generation cannot resurrect or erase work.
|
||||
|
||||
The retention audit found the missing ownership edge: runtime sessions own
|
||||
jobs/events, but native/OpenAI model rows had only request/conversation IDs and
|
||||
tools were linked only optionally. Semantic Mind/consequence documents in the
|
||||
same store are not session exhaust. The current cut adds typed
|
||||
`EpiphanyRuntimeModelExecutionBinding` plus one runtime-spine CAS that publishes
|
||||
session, job, opened event, binding, native request, and provider request
|
||||
atomically before transport. Collision and mismatched provider pairs leave no
|
||||
partial rows. Core hostile membership, CultNet Hello/catalog, and all 15 OpenAI
|
||||
runtime library tests pass. No archive deletion is authorized yet. Next, give
|
||||
model-derived and direct tool intents explicit execution ownership atomically;
|
||||
then map retained semantic references before building the archived-session
|
||||
tombstone.
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"$id": "https://gamecult.dev/epiphany/cultnet/epiphany.runtime.model-execution-binding.schema.json",
|
||||
"title": "Epiphany Runtime Model Execution Binding",
|
||||
"description": "Immutable ownership edge from one native/provider model request pair to its runtime session and job.",
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"schemaVersion": { "type": "string", "const": "epiphany.runtime.model_execution_binding.v0" },
|
||||
"bindingId": { "type": "string", "minLength": 1 },
|
||||
"requestId": { "type": "string", "minLength": 1 },
|
||||
"sessionId": { "type": "string", "minLength": 1 },
|
||||
"jobId": { "type": "string", "minLength": 1 },
|
||||
"provider": { "type": "string", "minLength": 1 },
|
||||
"boundAt": { "type": "string", "format": "date-time" }
|
||||
},
|
||||
"required": [
|
||||
"schemaVersion",
|
||||
"bindingId",
|
||||
"requestId",
|
||||
"sessionId",
|
||||
"jobId",
|
||||
"provider",
|
||||
"boundAt"
|
||||
]
|
||||
}
|
||||
|
|
@ -37,6 +37,17 @@
|
|||
"title": "Epiphany Runtime Session",
|
||||
"path": "epiphany.runtime.session.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.runtime.model-execution-binding.schema.json",
|
||||
"kind": "document_payload",
|
||||
"wireContracts": [
|
||||
"cultnet.schema.v0"
|
||||
],
|
||||
"schemaVersion": "epiphany.runtime.model_execution_binding.v0",
|
||||
"documentType": "epiphany.runtime.model_execution_binding",
|
||||
"title": "Epiphany Runtime Model Execution Binding",
|
||||
"path": "epiphany.runtime.model-execution-binding.schema.json"
|
||||
},
|
||||
{
|
||||
"schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.runtime.job.schema.json",
|
||||
"kind": "document_payload",
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ invariants:
|
|||
|
||||
current_status:
|
||||
summary: Epiphany is a supervised engineering alpha on Starfire, not deployment-ready. Exact b8138a6b active-child SIGTERM and restart, exact 9f369528 deterministic warm packaging, exact c930f505 cross-container ownership, exact ed15f83a resident lifecycle retention, and exact 16c4b19f coordinator receipt and Heartbeat artifact retention are proven. Gamecult-ops 059821f makes journald the sole Yggdrasil supervisor/projector stream-retention owner. Exact 16c4b19f genuine idle and exact a987d2f7 active cognition both completed 900-pulse bounded plateaus with clean direct-PID exits. The active run proves restart-persistent cooldown, exact-grant terminality under deliberate missing-ack and marker-regression corruption, multiple later terminal grants without resurrection, bounded artifact retention, and flat terminal resource state. Runtime-owned typed fulfillment is now accepted live: c1b461b2 falsified mutable Body/admission coupling, c9738fdb repaired the owner split, and exact 6dd9b132 packaging completed one autonomous Eyes continuation through coordinator exit, awaiting-fulfillment, one authenticated result, one planned acknowledgement, grant terminality, and clean shutdown. All 50 runtime-spine and 24 resident focused tests pass. Broad session/model/event/tool retention and stable Starfire firewall ownership remain open. Yggdrasil is the small public crossing body, never the release forge.
|
||||
latest_phase: Exact 6dd9b132 packaged in 8m47s as warning-free 24-binary release sha256-e9380f98b000e216705218c96f2925976558fff63113d5d003aed443ba80aadd with witness sha256-271f062be9b77d9a49d7aa26884c64db65c42919d30d8fecf650c7cb7890c86c. A fresh 7,678-file Active6 copy matched seven authority/store hashes exactly and published only that release. The exact pending autonomous proposal grant launched once. After coordinator exit, Self retained the same active lease as awaiting-fulfillment while detached Modeling continued. Runtime then admitted exact result-worker-cae0cad1-188e-46fa-832c-7cb0676422dd with checkpoint-update-needed and an Eyes continuation. Self completed at revision 21 with exactly one planned acknowledgement, terminalized the exact grant planned, persisted nextEligibleAtMillis=1786318158509, and did not duplicate result or acknowledgement during continued serve cycles. Tracked workspace changes are zero. SIGTERM completed in 577ms with exit zero and final braked. Receipts are under .epiphany-run/fulfillment-live-6dd9b132. Runtime-owned asynchronous typed fulfillment is accepted.
|
||||
latest_phase: Exact 6dd9b132 runtime-owned asynchronous fulfillment remains accepted. The broad retention audit proves runtime sessions are not yet complete deletion generations: model requests lack session/job identity, tools are only optionally linked to model requests, and durable semantic documents share the physical store without becoming session exhaust. Runtime spine now owns EpiphanyRuntimeModelExecutionBinding and one atomic open_runtime_model_execution CAS publishing session, job, opened event, binding, native request, and provider request before transport. Hostile collision/foreign-shape tests prove no partial family; CultNet Hello/catalog tests and all 15 OpenAI runtime tests pass. No archive deletion exists yet.
|
||||
operational_state:
|
||||
local_worktree: coordinator_receipt_retention_packaged_proven
|
||||
operator_wireguard: restored
|
||||
|
|
@ -69,7 +69,7 @@ current_status:
|
|||
yggdrasil_epiphany_service_contract: repaired_in_gamecult_ops_812b427_not_installed
|
||||
resident_physiology: authenticated_9b8df0b4_c005_bound_to_eyes_tools_nervous_system_with_217dd_and_bd96305e_helpers_running
|
||||
unresolved_authority: Coordinator receipt, Heartbeat pulse-artifact, deployed supervisor/projector log retention, genuine-idle and active resource plateaus, exact-grant terminality, restart-persistent cooldown refusal, schedule/action issuance cardinality, and runtime-owned typed fulfillment are accepted. Broader semantic/runtime session, job, event, model, and tool histories remain unbounded pending a typed archived-session owner. Repository Body observation still performs two authenticated full-tree Git index/manifest passes. Execute-mode workers require a persistent process body. Keyed storage has not earned live migration. One Discord consequence remains blocked by the absent Yggdrasil credential.
|
||||
next_action: Audit broad semantic/runtime retention before editing: map the owner, liveness inputs, retained evidence, deletion unit, cross-store references, and negative resurrection hazards for sessions, jobs, events, model requests/results/stream events, and tool intents/receipts. Design one typed archived-session authority that can retire only fully closed, unreferenced runtime generations under a snapshot fence; do not compact live or cross-store authority and do not add age-only deletion. Preserve active c005 and the accepted fulfillment receipts. Yggdrasil never builds.
|
||||
next_action: Cut tool execution ownership before archival: model-derived intents must inherit an exact EpiphanyRuntimeModelExecutionBinding through model_request_id, while direct intents require an explicit session/job owner. Publish each intent and owner edge atomically before it can become pending; preserve legacy unbound intents as unarchivable. Then map retained semantic references and implement one typed archived-session tombstone with snapshot-fenced exact deletion. Preserve active c005 and accepted fulfillment receipts. Yggdrasil never builds.
|
||||
|
||||
active_subgoals:
|
||||
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.
|
||||
|
|
|
|||
Reference in a new issue