Retain Self authority until typed fulfillment

This commit is contained in:
Meta Vens 2026-08-09 19:19:47 +01:00
commit 30a63d6361
6 changed files with 656 additions and 81 deletions

View file

@ -7,16 +7,16 @@ use epiphany_core::{
ResidentSelfState, acknowledge_resident_self_launch, acquire_resident_process_singleton,
authenticate_resident_self_policy, bind_runtime_repository_domain,
bridge_admitted_persona_feedback_to_heartbeat, cancel_resident_self_turn,
capture_process_instance, complete_resident_self_turn, coordinator_run_receipts,
derive_resident_cognition_readiness, enqueue_resident_self_pressure,
import_bifrost_persona_feedback_deliveries, ingest_resident_self_domain_pressure,
load_epiphany_cultmesh_swarm_brake, load_resident_self_state, observe_process_instance,
pending_resident_self_acks, prepare_resident_self_launch, publish_resident_provider_readiness,
capture_process_instance, coordinator_run_receipts, derive_resident_cognition_readiness,
enqueue_resident_self_pressure, import_bifrost_persona_feedback_deliveries,
ingest_resident_self_domain_pressure, load_epiphany_cultmesh_swarm_brake,
load_resident_self_state, observe_process_instance, pending_resident_self_acks,
prepare_resident_self_launch, publish_resident_provider_readiness,
resident_prepared_launch_thread_id, resident_self_child_claim,
resident_self_local_provider_status, terminate_process_instance,
retain_coordinator_run_receipts, retain_resident_self_lifecycles,
validate_persona_feedback_store_separation,
validate_resident_self_store_separation, verify_resident_self_grant_fulfillment,
resident_self_local_provider_status, retain_coordinator_run_receipts,
retain_resident_self_lifecycles, settle_resident_self_exited_coordinator,
terminate_process_instance, validate_persona_feedback_store_separation,
validate_resident_self_store_separation,
};
use serde_json::json;
use std::collections::{BTreeMap, BTreeSet};
@ -350,24 +350,18 @@ fn cycle(
"coordinator exited zero without its exact resident terminal receipt"
)
})?;
if let Err(error) = verify_resident_self_grant_fulfillment(
let outcome = settle_resident_self_exited_coordinator(
&args.state_store,
&args.policy.runtime_store,
&lease.grant_id,
) {
cancel_resident_self_turn(
&args.state_store,
&lease,
"unfulfilled",
&error.to_string(),
now,
)?;
*state = load_resident_self_state(&args.state_store)?;
return Ok(ResidentSelfOutcome::Failed);
}
complete_resident_self_turn(&args.state_store, &lease, &receipt, now)?;
&lease,
&receipt,
shutdown_requested,
brake_engaged,
timed_out,
now,
)?;
*state = load_resident_self_state(&args.state_store)?;
Ok(ResidentSelfOutcome::Completed)
Ok(outcome)
}
ChildObservation::Exited(code) => {
cancel_resident_self_turn(
@ -428,7 +422,7 @@ fn summary(
) -> serde_json::Value {
json!({
"schemaVersion": "epiphany.resident_self.operator_projection.v0",
"status": format!("{outcome:?}").to_ascii_lowercase(),
"status": outcome.operator_status(),
"revision": state.revision,
"activeTurnId": state.active_turn.as_ref().map(|turn| &turn.turn_id),
"shutdownRequested": shutdown_requested,
@ -749,6 +743,14 @@ mod brake_tests {
assert_eq!(outcome_after_cancel(false), ResidentSelfOutcome::Failed);
}
#[test]
fn terminal_fulfillment_has_explicit_operator_projection() {
assert_eq!(
ResidentSelfOutcome::AwaitingFulfillment.operator_status(),
"awaiting-fulfillment"
);
}
#[test]
fn shutdown_wait_returns_immediately_when_already_requested() {
let requested = AtomicBool::new(true);

View file

@ -360,6 +360,10 @@ pub fn validate_candidate(
request: &ImaginationConsiderationRequest,
candidate: &ImaginationConsiderationCandidate,
) -> Result<()> {
let requested_at = chrono::DateTime::parse_from_rfc3339(&request.requested_at)
.map_err(|_| anyhow!("consideration request timestamp is invalid"))?;
let proposed_at = chrono::DateTime::parse_from_rfc3339(&candidate.proposed_at)
.map_err(|_| anyhow!("consideration candidate timestamp is invalid"))?;
validate_visibility_classification(
&candidate.source_visibility,
&candidate.data_classification,
@ -385,7 +389,7 @@ pub fn validate_candidate(
.source_discussion_refs
.contains(reference)
})
|| chrono::DateTime::parse_from_rfc3339(&candidate.proposed_at).is_err()
|| proposed_at < requested_at
{
bail!("candidate substituted causal identity");
}
@ -491,8 +495,8 @@ mod tests {
#[test]
fn cold_runtime_without_thread_defers_feedback_consideration() -> Result<()> {
let temp = tempfile::tempdir()?;
let runtime = temp.path().join("runtime.ccmp");
let feedback = temp.path().join("feedback.ccmp");
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,
@ -610,6 +614,13 @@ mod tests {
}
}
#[test]
fn candidate_cannot_predate_its_request() {
let mut candidate = candidate(ImaginationConsiderationDisposition::Suggest);
candidate.proposed_at = "2026-07-17T23:59:59Z".into();
assert!(validate_candidate(&request(), &candidate).is_err());
}
#[test]
fn no_fit_is_terminal_and_cannot_smuggle_options() {
let mut candidate = candidate(ImaginationConsiderationDisposition::NoFit);

View file

@ -518,11 +518,33 @@ pub enum ResidentSelfOutcome {
Draining,
Sleeping,
Running,
AwaitingFulfillment,
Launched,
Completed,
Failed,
}
impl ResidentSelfOutcome {
pub fn operator_status(&self) -> &'static str {
match self {
Self::Braked => "braked",
Self::Draining => "draining",
Self::Sleeping => "sleeping",
Self::Running => "running",
Self::AwaitingFulfillment => "awaiting-fulfillment",
Self::Launched => "launched",
Self::Completed => "completed",
Self::Failed => "failed",
}
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ResidentSelfGrantFulfillment {
Fulfilled,
Pending,
}
pub fn coordinator_argv(
policy: &ResidentSelfPolicy,
turn_id: &str,
@ -1115,30 +1137,158 @@ pub fn verify_resident_self_grant_fulfillment(
resident_store: &Path,
runtime_store: &Path,
grant_id: &str,
) -> Result<()> {
) -> Result<ResidentSelfGrantFulfillment> {
let grant = state_cache(resident_store)?
.get::<ResidentSelfHeartbeatGrant>(grant_id)?
.ok_or_else(|| anyhow!("resident Self fulfillment check lost its grant"))?;
if grant.pressure_kind != "repo-frontier-proposal-modeling" {
return Ok(());
}
let request_id = grant
.provenance_ref
.strip_prefix("cultcache://repo-frontier-proposal-modeling/")
.filter(|value| !value.trim().is_empty())
.ok_or_else(|| anyhow!("proposal Modeling grant lost exact request provenance"))?;
let mut runtime = crate::runtime_spine_cache(runtime_store)?;
runtime.pull_all_backing_stores()?;
if !runtime
.get_all::<crate::RepoFrontierProposalModelingLaunchBinding>()?
.iter()
.any(|binding| binding.proposal_modeling_request_id == request_id)
{
return Err(anyhow!(
"proposal Modeling pressure completed without its exact launch binding"
));
let worker_results = runtime.get_all::<crate::EpiphanyRuntimeRoleWorkerResult>()?;
match grant.pressure_kind.as_str() {
"repo-frontier-proposal-modeling" => {
let request_id = grant
.provenance_ref
.strip_prefix("cultcache://repo-frontier-proposal-modeling/")
.filter(|value| !value.trim().is_empty())
.ok_or_else(|| anyhow!("proposal Modeling grant lost exact request provenance"))?;
Ok(
if worker_results.iter().any(|result| {
result.proposal_modeling_request_id.as_deref() == Some(request_id)
}) {
ResidentSelfGrantFulfillment::Fulfilled
} else {
ResidentSelfGrantFulfillment::Pending
},
)
}
"admitted-model-direction-consideration" => {
let request_id = grant
.provenance_ref
.strip_prefix("cultcache://admitted-model-direction-consideration/")
.filter(|value| !value.trim().is_empty())
.ok_or_else(|| anyhow!("model direction grant lost exact request provenance"))?;
let request = runtime
.get::<crate::AdmittedModelDirectionConsiderationRequest>(request_id)?
.ok_or_else(|| anyhow!("model direction fulfillment request is missing"))?;
for worker_result in worker_results.iter().filter(|result| {
result
.admitted_model_direction_consideration_request_id
.as_deref()
== Some(request_id)
}) {
let result = worker_result
.admitted_model_direction_consideration_result()?
.ok_or_else(|| anyhow!("model direction worker result lost typed companion"))?;
crate::validate_admitted_model_direction_consideration_result(&request, &result)?;
if runtime
.get::<crate::AdmittedModelDirectionConsiderationResult>(&result.result_id)?
.as_ref()
!= Some(&result)
{
return Err(anyhow!(
"model direction worker result lost its persisted typed companion"
));
}
return Ok(ResidentSelfGrantFulfillment::Fulfilled);
}
Ok(ResidentSelfGrantFulfillment::Pending)
}
"imagination-consideration" => {
let request_id = grant
.provenance_ref
.strip_prefix("cultcache://imagination-consideration/")
.filter(|value| !value.trim().is_empty())
.ok_or_else(|| {
anyhow!("Imagination consideration grant lost exact request provenance")
})?;
let request = runtime
.get::<crate::ImaginationConsiderationRequest>(request_id)?
.ok_or_else(|| {
anyhow!("Imagination consideration fulfillment request is missing")
})?;
for worker_result in worker_results.iter().filter(|result| {
result.imagination_consideration_request_id.as_deref() == Some(request_id)
}) {
let candidate = worker_result
.imagination_consideration_candidate()?
.ok_or_else(|| anyhow!("Imagination worker result lost typed candidate"))?;
crate::validate_imagination_consideration_candidate(&request, &candidate)?;
if candidate.candidate_id
!= crate::imagination_consideration_candidate_id_for_launch(
request_id,
&worker_result.job_id,
)
|| runtime
.get::<crate::ImaginationConsiderationCandidate>(&candidate.candidate_id)?
.as_ref()
!= Some(&candidate)
{
return Err(anyhow!(
"Imagination worker result lost its exact persisted candidate"
));
}
return Ok(ResidentSelfGrantFulfillment::Fulfilled);
}
Ok(ResidentSelfGrantFulfillment::Pending)
}
_ => Ok(ResidentSelfGrantFulfillment::Fulfilled),
}
}
pub fn settle_resident_self_exited_coordinator(
resident_store: &Path,
runtime_store: &Path,
lease: &ResidentSelfTurnLease,
receipt: &crate::EpiphanyCoordinatorRunReceipt,
shutdown_requested: bool,
brake_engaged: bool,
timed_out: bool,
now_millis: u64,
) -> Result<ResidentSelfOutcome> {
match verify_resident_self_grant_fulfillment(resident_store, runtime_store, &lease.grant_id) {
Ok(ResidentSelfGrantFulfillment::Pending)
if !(shutdown_requested || brake_engaged || timed_out) =>
{
Ok(ResidentSelfOutcome::AwaitingFulfillment)
}
Ok(ResidentSelfGrantFulfillment::Pending) => {
let status = if shutdown_requested {
"shutdown-cancelled"
} else if brake_engaged {
"brake-cancelled"
} else if timed_out {
"timed-out"
} else {
"process-failed"
};
cancel_resident_self_turn(
resident_store,
lease,
status,
"coordinator exited before its exact typed grant fulfillment became terminal",
now_millis,
)?;
Ok(if shutdown_requested {
ResidentSelfOutcome::Braked
} else {
ResidentSelfOutcome::Failed
})
}
Err(error) => {
cancel_resident_self_turn(
resident_store,
lease,
"unfulfilled",
&error.to_string(),
now_millis,
)?;
Ok(ResidentSelfOutcome::Failed)
}
Ok(ResidentSelfGrantFulfillment::Fulfilled) => {
complete_resident_self_turn(resident_store, lease, receipt, now_millis)?;
Ok(ResidentSelfOutcome::Completed)
}
}
Ok(())
}
pub fn pending_resident_self_grant(path: &Path) -> Result<Option<ResidentSelfHeartbeatGrant>> {
@ -1428,7 +1578,7 @@ pub fn resident_self_child_claim(
.get::<ResidentSelfChildClaim>(&format!("resident-self-child-claim-{preparation_id}"))
}
pub fn complete_resident_self_turn(
fn complete_resident_self_turn(
path: &Path,
lease: &ResidentSelfTurnLease,
coordinator: &crate::EpiphanyCoordinatorRunReceipt,
@ -2119,6 +2269,75 @@ mod tests {
SingleFileMessagePackBackingStore::new(store).push(&entry)?;
Ok(())
}
fn role_worker_result(job_id: &str, role_id: &str) -> crate::EpiphanyRuntimeRoleWorkerResult {
crate::EpiphanyRuntimeRoleWorkerResult {
schema_version: crate::RUNTIME_ROLE_WORKER_RESULT_SCHEMA_VERSION.into(),
result_id: format!("result-{job_id}"),
job_id: job_id.into(),
role_id: role_id.into(),
verdict: "pass".into(),
summary: "Typed worker completed its bounded request.".into(),
next_safe_move: "Return authority to resident Self.".into(),
checkpoint_summary: None,
scratch_summary: None,
files_inspected: vec![],
frontier_node_ids: vec![],
evidence_ids: vec![],
artifact_refs: vec![],
open_questions: vec![],
evidence_gaps: vec![],
risks: vec![],
state_patch_msgpack: None,
self_patch_msgpack: None,
item_error: None,
metadata: BTreeMap::new(),
repo_model_patch_msgpack: None,
verification_request_id: None,
frontier_route_id: None,
repo_frontier_modeling_request_id: None,
proposal_modeling_request_id: None,
claim_repair_request_id: None,
frontier_planning_request_id: None,
frontier_plan_candidate_msgpack: None,
frontier_plan_mind_request_id: None,
frontier_plan_mind_decision_msgpack: None,
repository_body_observation_basis: None,
imagination_consideration_request_id: None,
imagination_consideration_candidate_msgpack: None,
admitted_model_direction_consideration_request_id: None,
admitted_model_direction_consideration_result_msgpack: None,
}
}
fn coordinator_receipt_for_lease(
lease: &ResidentSelfTurnLease,
runtime_store: &Path,
) -> crate::EpiphanyCoordinatorRunReceipt {
crate::EpiphanyCoordinatorRunReceipt {
schema_version: crate::COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION.into(),
receipt_id: format!("coordinator-terminal-{}", lease.turn_id),
session_id: format!("session-{}", lease.turn_id),
thread_id: lease.turn_id.clone(),
mode: "plan".into(),
status: "planned".into(),
final_action: "propose".into(),
final_reason: None,
step_count: 1,
created_at: "2026-07-18T00:00:00Z".into(),
model_provider: Some("local".into()),
runtime_store: runtime_store.display().to_string(),
artifact_refs: vec![],
sealed_artifact_refs: vec![],
metadata: Default::default(),
resident_grant_id: Some(lease.grant_id.clone()),
resident_launch_digest: Some(lease.launch_digest.clone()),
resident_policy_digest: Some(lease.policy_digest.clone()),
resident_argv_digest: Some(lease.argv_digest.clone()),
resident_objective_digest: Some(lease.objective_digest.clone()),
resident_release_commit: Some(lease.release_commit.clone()),
resident_release_manifest_digest: Some(lease.release_manifest_digest.clone()),
resident_executable_digest: Some(lease.coordinator_executable_digest.clone()),
}
}
fn seed_proposal_modeling_request(
store: &Path,
request_id: &str,
@ -2337,8 +2556,287 @@ mod tests {
let mut wrong = receipt.clone();
wrong.resident_release_commit = Some("unwitnessed-release".into());
assert!(complete_resident_self_turn(&store, &lease, &wrong, 8).is_err());
let ack = complete_resident_self_turn(&store, &lease, &receipt, 9)?;
assert_eq!(ack.coordinator_receipt_id, receipt.receipt_id);
assert_eq!(
settle_resident_self_exited_coordinator(
&store,
&policy.runtime_store,
&lease,
&receipt,
false,
false,
false,
9,
)?,
ResidentSelfOutcome::AwaitingFulfillment
);
assert_eq!(
load_resident_self_state(&store)?.active_turn.as_ref(),
Some(&lease)
);
assert!(pending_resident_self_acks(&store)?.is_empty());
let runtime = crate::runtime_spine_cache(&policy.runtime_store)?;
let result = crate::AdmittedModelDirectionConsiderationResult {
schema_version: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_RESULT_SCHEMA_VERSION
.into(),
result_id: "result-model-1".into(),
request_id: "request-model-1".into(),
runtime_id: policy.release_runtime_id.clone(),
thread_id: "implementation-thread-1".into(),
model_revision: 1,
model_hash: "sha256:model-1".into(),
model_admission_receipt_id: "model-admission-1".into(),
disposition: crate::AdmittedModelDirectionDisposition::Hold,
summary: "Hold while the current admitted direction remains coherent.".into(),
option_drafts: vec![],
uncertainties: vec![],
evidence_refs: vec!["model-admission-1".into()],
proposed_at: "2026-07-18T00:00:01Z".into(),
contract: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_RESULT_CONTRACT.into(),
proposal_only: true,
terminal: true,
};
let (result_entry, _) = runtime.prepare_entry(&result.result_id, &result)?;
SingleFileMessagePackBackingStore::new(&policy.runtime_store).push(&result_entry)?;
let mut worker = role_worker_result("job-model-1", "imagination");
worker.admitted_model_direction_consideration_request_id = Some("request-model-1".into());
worker.admitted_model_direction_consideration_result_msgpack =
Some(rmp_serde::to_vec_named(&result)?);
let (worker_entry, _) = runtime.prepare_entry(&worker.job_id, &worker)?;
SingleFileMessagePackBackingStore::new(&policy.runtime_store).push(&worker_entry)?;
assert_eq!(
settle_resident_self_exited_coordinator(
&store,
&policy.runtime_store,
&lease,
&receipt,
false,
false,
false,
10,
)?,
ResidentSelfOutcome::Completed
);
assert!(load_resident_self_state(&store)?.active_turn.is_none());
let acks = pending_resident_self_acks(&store)?;
assert_eq!(acks.len(), 1);
assert_eq!(acks[0].coordinator_receipt_id, receipt.receipt_id);
Ok(())
}
#[test]
fn model_direction_grant_waits_for_exact_terminal_imagination_result() -> Result<()> {
let temp = tempfile::tempdir()?;
let resident_store = temp.path().join("resident-self.cc");
let runtime_store = temp.path().join("runtime.cc");
seed_model_direction_request(
&runtime_store,
"request-model-fulfillment",
"test-runtime",
"implementation-thread-1",
)?;
enqueue_resident_self_pressure(
&resident_store,
&ResidentSelfPressure {
schema_version: RESIDENT_SELF_PRESSURE_SCHEMA_VERSION.into(),
pressure_id: "pressure-model-fulfillment".into(),
kind: "admitted-model-direction-consideration".into(),
provenance_ref:
"cultcache://admitted-model-direction-consideration/request-model-fulfillment"
.into(),
objective: "Consider the admitted model direction through Imagination.".into(),
created_at_millis: 1,
status: "pending".into(),
consumed_by_grant_id: None,
private_state_exposed: false,
},
)?;
let grant = heartbeat_issue_resident_self_grant(
&resident_store,
"heartbeat-model-fulfillment",
"action-model-fulfillment",
2,
)?
.expect("model direction grant");
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Pending
);
let runtime = crate::runtime_spine_cache(&runtime_store)?;
let result = crate::AdmittedModelDirectionConsiderationResult {
schema_version: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_RESULT_SCHEMA_VERSION
.into(),
result_id: "result-model-fulfillment".into(),
request_id: "request-model-fulfillment".into(),
runtime_id: "test-runtime".into(),
thread_id: "implementation-thread-1".into(),
model_revision: 1,
model_hash: "sha256:model-1".into(),
model_admission_receipt_id: "model-admission-1".into(),
disposition: crate::AdmittedModelDirectionDisposition::Hold,
summary: "Hold while the current admitted direction remains coherent.".into(),
option_drafts: vec![],
uncertainties: vec![],
evidence_refs: vec!["model-admission-1".into()],
proposed_at: "2026-07-18T00:00:01Z".into(),
contract: crate::ADMITTED_MODEL_DIRECTION_CONSIDERATION_RESULT_CONTRACT.into(),
proposal_only: true,
terminal: true,
};
let (entry, _) = runtime.prepare_entry(&result.result_id, &result)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&entry)?;
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Pending
);
let mut worker = role_worker_result("job-model-fulfillment", "imagination");
worker.admitted_model_direction_consideration_request_id =
Some("request-model-fulfillment".into());
worker.admitted_model_direction_consideration_result_msgpack =
Some(rmp_serde::to_vec_named(&result)?);
let (worker_entry, _) = runtime.prepare_entry(&worker.job_id, &worker)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&worker_entry)?;
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Fulfilled
);
Ok(())
}
#[test]
fn feedback_imagination_grant_waits_for_exact_bound_candidate() -> Result<()> {
let temp = tempfile::tempdir()?;
let resident_store = temp.path().join("resident-self.cc");
let runtime_store = temp.path().join("runtime.cc");
let runtime = crate::runtime_spine_cache(&runtime_store)?;
let request = crate::ImaginationConsiderationRequest {
schema_version: crate::IMAGINATION_CONSIDERATION_REQUEST_SCHEMA_VERSION.into(),
request_id: "request-imagination-fulfillment".into(),
feedback_id: "feedback-1".into(),
feedback_admission_id: "feedback-admission-1".into(),
feedback_packet_sha256: "sha256:feedback-1".into(),
source_room_id: "room-1".into(),
source_visibility: "public".into(),
data_classification: "public_feedback".into(),
source_provider_identity_id: "provider-1".into(),
runtime_id: "test-runtime".into(),
thread_id: "implementation-thread-1".into(),
repository: "GameCult/Epiphany".into(),
persona_id: "epiphany".into(),
model_revision: 1,
model_hash: "sha256:model-1".into(),
model_admission_receipt_id: "model-admission-1".into(),
routing_policy_id: "routing-policy-1".into(),
question: crate::ImaginationConsiderationQuestion::CompareWithCurrentBodyAndSuggestCoherentOptions,
quoted_evidence: crate::QuotedPersonaFeedbackEvidence {
feedback_text: "Consider a quieter operator surface.".into(),
source_discussion_refs: vec!["discussion-1".into()],
source_room_id: "room-1".into(),
source_visibility: "public".into(),
data_classification: "public_feedback".into(),
source_actor_id: "actor-1".into(),
source_provider: "discord".into(),
},
requested_at: "2026-07-18T00:00:00Z".into(),
contract: crate::IMAGINATION_CONSIDERATION_REQUEST_CONTRACT.into(),
private_state_included: false,
};
let (request_entry, _) = runtime.prepare_entry(&request.request_id, &request)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&request_entry)?;
enqueue_resident_self_pressure(
&resident_store,
&ResidentSelfPressure {
schema_version: RESIDENT_SELF_PRESSURE_SCHEMA_VERSION.into(),
pressure_id: "pressure-imagination-fulfillment".into(),
kind: "imagination-consideration".into(),
provenance_ref:
"cultcache://imagination-consideration/request-imagination-fulfillment".into(),
objective: "Consider admitted feedback through Imagination.".into(),
created_at_millis: 1,
status: "pending".into(),
consumed_by_grant_id: None,
private_state_exposed: false,
},
)?;
let grant = heartbeat_issue_resident_self_grant(
&resident_store,
"heartbeat-imagination-fulfillment",
"action-imagination-fulfillment",
2,
)?
.expect("Imagination consideration grant");
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Pending
);
let worker_job_id = "job-imagination-fulfillment";
let candidate = crate::ImaginationConsiderationCandidate {
schema_version: crate::IMAGINATION_CONSIDERATION_CANDIDATE_SCHEMA_VERSION.into(),
candidate_id: crate::imagination_consideration_candidate_id_for_launch(
&request.request_id,
worker_job_id,
),
request_id: request.request_id.clone(),
feedback_id: request.feedback_id.clone(),
feedback_packet_sha256: request.feedback_packet_sha256.clone(),
model_revision: request.model_revision,
model_hash: request.model_hash.clone(),
disposition: crate::ImaginationConsiderationDisposition::NoFit,
title: "No coherent fit".into(),
summary: "The feedback does not yet justify a Body change.".into(),
rationale: "Current evidence is insufficient.".into(),
option_drafts: vec![],
uncertainties: vec![],
evidence_refs: vec!["discussion-1".into()],
recommended_review_route: crate::ImaginationConsiderationReviewRoute::Silence,
proposed_at: "2026-07-18T00:00:02Z".into(),
contract: crate::IMAGINATION_CONSIDERATION_CANDIDATE_CONTRACT.into(),
source_room_id: request.source_room_id.clone(),
source_visibility: request.source_visibility.clone(),
data_classification: request.data_classification.clone(),
};
let (candidate_entry, _) = runtime.prepare_entry(&candidate.candidate_id, &candidate)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&candidate_entry)?;
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Pending
);
let mut worker = role_worker_result(worker_job_id, "imagination");
worker.imagination_consideration_request_id = Some(request.request_id.clone());
worker.imagination_consideration_candidate_msgpack =
Some(rmp_serde::to_vec_named(&candidate)?);
let (worker_entry, _) = runtime.prepare_entry(&worker.job_id, &worker)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&worker_entry)?;
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Fulfilled
);
Ok(())
}
@ -2446,14 +2944,18 @@ mod tests {
claim_resident_self_preparation_as_child(&store, &prepared.preparation_id, &process, 4)?;
let lease =
acknowledge_resident_self_launch(&store, &prepared.preparation_id, &process, 5)?;
let ack = cancel_resident_self_turn(
let receipt = coordinator_receipt_for_lease(&lease, &policy.runtime_store);
let outcome = settle_resident_self_exited_coordinator(
&store,
&policy.runtime_store,
&lease,
"shutdown-cancelled",
"resident process received an operator shutdown signal",
&receipt,
true,
false,
false,
6,
)?;
assert_eq!(ack.terminal_status, "shutdown-cancelled");
assert_eq!(outcome, ResidentSelfOutcome::Braked);
let cache = state_cache(&store)?;
let state = cache
.get::<ResidentSelfState>(RESIDENT_SELF_STATE_KEY)?
@ -2465,6 +2967,28 @@ mod tests {
.expect("requeued pressure");
assert_eq!(pressure.status, "pending");
assert_eq!(pressure.consumed_by_grant_id, None);
let acknowledgements = state_cache(&store)?.get_all::<ResidentSelfTerminalAck>()?;
assert_eq!(acknowledgements.len(), 1);
assert_eq!(acknowledgements[0].terminal_status, "shutdown-cancelled");
assert!(
settle_resident_self_exited_coordinator(
&store,
&policy.runtime_store,
&lease,
&receipt,
true,
false,
false,
7,
)
.is_err()
);
assert_eq!(
state_cache(&store)?
.get_all::<ResidentSelfTerminalAck>()?
.len(),
1
);
Ok(())
}
@ -2574,13 +3098,13 @@ mod tests {
2,
)?
.expect("queue-head grant");
assert!(
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)
.is_err()
)?,
ResidentSelfGrantFulfillment::Pending
);
let runtime_cache = crate::runtime_spine_cache(&runtime_store)?;
@ -2599,9 +3123,20 @@ mod tests {
worker_launch_document_sha256: "33".repeat(32),
contract: crate::REPO_FRONTIER_PROPOSAL_MODELING_LAUNCH_BINDING_CONTRACT.into(),
};
let (entry, _) = runtime_cache.prepare_entry(&launch.binding_record_id, &launch)?;
let (launch_entry, _) = runtime_cache.prepare_entry(&launch.binding_record_id, &launch)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&launch_entry)?;
let mut worker = role_worker_result("modeling-job-1", "modeling");
worker.proposal_modeling_request_id = Some("selection-1".into());
let (entry, _) = runtime_cache.prepare_entry(&worker.job_id, &worker)?;
SingleFileMessagePackBackingStore::new(&runtime_store).push(&entry)?;
verify_resident_self_grant_fulfillment(&resident_store, &runtime_store, &grant.grant_id)?;
assert_eq!(
verify_resident_self_grant_fulfillment(
&resident_store,
&runtime_store,
&grant.grant_id,
)?,
ResidentSelfGrantFulfillment::Fulfilled
);
assert_eq!(
ingest_resident_self_domain_pressure(

View file

@ -1324,15 +1324,23 @@ heartbeat owns opportunity without acquiring a second scheduling opinion.
Resident terminal success is also pressure-specific. For a
`repo-frontier-proposal-modeling` grant, a zero-exit coordinator receipt proves
only that the bounded coordinator process ended cleanly; it does not prove the
requested Modeling launch occurred. Before acknowledging that pressure,
resident Self now requires the runtime spine to contain the exact
`RepoFrontierProposalModelingLaunchBinding`. Missing fulfillment is a typed
failed turn: the same cancellation authority used by process failure, timeout,
and brake cancellation admits the `unfulfilled` terminal class and atomically
requeues the same pressure for heartbeat retry. The producer of a terminal
class and the cancellation contract must evolve together; otherwise the
runtime errors before the requeue CAS and leaves physiology split across an
active resident lease and an uncompleted heartbeat turn.
requested Modeling work reached a typed terminal result. The resident active
turn therefore remains the sole acknowledgement owner after coordinator exit.
For proposal Modeling it requires the runtime-owned worker result echoing the
exact proposal request. For admitted model-direction and Imagination
consideration it additionally validates the exact typed result/candidate and
requires that byte-identical companion to exist in the runtime store. Missing
terminal evidence is `awaiting-fulfillment`: the active lease remains live and
cannot be retained, relaunched, acknowledged, or requeued. A later serve cycle
consumes the route exactly once when the typed evidence appears. Brake,
shutdown, or timeout while waiting uses the existing cancellation CAS to close
the lease once and return its exact pressure to Heartbeat; invalid or
substituted evidence closes as `unfulfilled`. Coordinator process closure is
therefore evidence, never cognitive completion authority.
Imagination candidate time is part of that causal contract. A candidate must
have a valid RFC3339 timestamp at or after its request timestamp. A
well-shaped candidate from before the request cannot close resident authority.
Typed resident launches run the bounded coordinator in planning mode so an
ordinary operator objective cannot silently become actuation. Request-owned

View file

@ -1063,16 +1063,17 @@ artifact payload stayed at 13,175 bytes in one pulse directory. This is useful
bounded active-marker/braked-Self physiology, not an idle cognition claim: the
copied Heartbeat store retained a stale coordinator participant marked running.
A genuine idle control is now active in
`.epiphany-run/idle-control-16c4b19f`. Exact packaged `epiphany-verse-query`
engaged the canonical typed `epiphany/swarm-brake` under runtime
`epiphany-starfire-linux` in both root and Eyes local-Verse stores. Heartbeat
therefore reports `braked-after-ack-reconciliation` with the exact brake ID and
Self reports braked. Direct-PID containers are
`epiphany-linux-idle-control-heartbeat-16c4b19f` and
`epiphany-linux-idle-control-self-16c4b19f`; hidden monitor PID 22912 samples
CPU/RSS/store/artifacts and will stop Self after 900 pulses. Poll only; do not
start a duplicate or disturb active c005.
A genuine idle control in `.epiphany-run/idle-control-16c4b19f` is complete.
Exact packaged `epiphany-verse-query` engaged the canonical typed
`epiphany/swarm-brake` under runtime `epiphany-starfire-linux` in both root and
Eyes local-Verse stores. Heartbeat completed 900 one-second refused pulses and
exited zero; the monitor then sent direct-PID SIGTERM to Self, which also exited
zero with shutdown requested. Across 139 comparable Heartbeat samples RSS was
27.77--28.52 MiB and first/last-quarter averages changed by 0.0068 MiB. Across
141 Self samples RSS was 26.97--27.73 MiB and the quarter delta was 0.0423 MiB.
Aggregate copied state stayed exactly 7,332,259 bytes and artifact payload
stayed zero. This is the accepted no-cognition baseline. Active c005 remained
untouched.
The bounded active-cognition endurance pass has an authority map; do not
replace it with a synthetic busy fixture. Resident Self owns consumption of one
@ -1095,6 +1096,24 @@ artifacts, and clean direct-PID shutdown. If the request or grant is absent,
resolved, or mismatched, stop and choose a new request through its production
typed owner; do not manufacture endurance theater.
Source inspection before active endurance found a continuity fault in the
resident closure path. A zero-exit bounded coordinator can publish its exact
coordinator receipt before a detached typed worker result appears; the old
cycle acknowledged the grant immediately and could permanently consume its
pressure if the worker later failed. Resident Self now keeps the active lease
and projects `awaiting-fulfillment` until the runtime-owned worker result and
exact typed companion prove terminal cognition. Proposal Modeling requires its
exact echoed request; admitted model-direction and Imagination consideration
also validate and compare their persisted typed result/candidate. Brake,
shutdown, and timeout cancel and requeue the exact pressure once through the
existing CAS. The raw completion primitive is private to this settling seam.
Imagination candidates must not predate their request. Twenty-two resident
tests, eight swarm binary tests, and eight Imagination consideration tests pass,
including exited-zero pending-to-fulfilled closure and exact-once shutdown
requeue. This cut is not packaged yet. Commit and publish it, package the exact
source with the persistent Starfire cache, authenticate all 24 binaries and
witness, then use only that release for active cognition endurance.
Resident lifecycle retention is now implemented in source. Resident Self's
serve/once owner invokes a configurable `--retained-closed-lifecycles` bound
(default 256). Only Heartbeat-consumed terminal lifecycles whose pressure still

View file

@ -35,8 +35,8 @@ invariants:
- Evidence and git retain history; this map retains only state that changes future decisions.
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 retention are proven. Packaged 16c4b19f also proves Heartbeat pulse-artifact retention and idempotent replay. Gamecult-ops 059821f makes journald the sole Yggdrasil supervisor/projector stream-retention owner. Broad session/model/event/tool retention, the long-duration plateau, and stable Starfire firewall ownership remain open. Yggdrasil is the small public crossing body, never the release forge.
latest_phase: Commit 76afdaf0 moved release construction, filesystem verification, and witness inspection out of monolithic epiphany-core into epiphany-release-construction; core retains only CultMesh publication, load, and authentication. The bootstrap dependency graph excludes epiphany-core, all 19 construction tests pass, and the full core test harness compiles. Exact Linux bootstrap fell from 7m57s to 30.24s cold and 4.40s warm. Exact source 76afdaf0 then produced warning-free 24-binary release sha256-30caab9ef1ea89f9a885d87832b1e312a35288ec3f895bd5b0e83f7f7a6a1aec with witness sha256-89c2ad604254faec3e1e01f753b5dff38a402f43d009074ba4b47b1ec46fdecf. Independent inspection accepted the 12m16s cold build and the identical 10.16s warm replay with Cargo at 0.82s. The packaged full publisher accepted the narrow constructor's witness and changed c005 local-verse.cc from SHA-256 b160c610988753278afbad7f5bad436193144a92e9fd506982099ad58d213909 to 83ed430f5bf0c33996d7c4ee7bf0fa6c9f5f80bc8db94621395ea560852cae81 without body activation.
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. The exact 16c4b19f genuine-idle control completed 900 refused pulses with constant state, zero artifacts, flat RSS, and clean direct-PID exits. Typed active cognition endurance, 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: Resident closure source now separates process termination from cognitive fulfillment. A zero-exit coordinator with its exact receipt retains the active lease as awaiting-fulfillment until the runtime-owned worker result and exact typed companion prove the grant terminal; brake, shutdown, or timeout cancels and requeues once through the existing CAS. The raw completion writer is private to that settling seam, and Imagination candidates cannot predate their request. Twenty-two resident tests, eight swarm binary tests, and eight Imagination consideration tests pass. The cut remains uncommitted and unpackaged.
operational_state:
local_worktree: coordinator_receipt_retention_packaged_proven
operator_wireguard: restored
@ -68,8 +68,8 @@ current_status:
starfire_linux_modeling_peak: 109887488_bytes_resident_body_plus_modeling_circuit
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, and deployed supervisor/projector log retention are accepted. Broader semantic/runtime histories remain unbounded pending a typed archived-session owner. The long-duration idle/active resource plateau remains unproven. 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: Poll the exact 16c4b19f dual-brake idle control already running under epiphany-linux-idle-control-heartbeat-16c4b19f and epiphany-linux-idle-control-self-16c4b19f; do not duplicate it. On clean completion, analyze its full CPU/RSS/store/artifact series and direct-PID shutdown, then design the bounded active-cognition endurance pass. Preserve active c005. Do not compact session/model/event/tool history until typed archived-session ownership exists.
unresolved_authority: Coordinator receipt, Heartbeat pulse-artifact, deployed supervisor/projector log retention, and the genuine-idle resource plateau are accepted. Broader semantic/runtime histories remain unbounded pending a typed archived-session owner. Active cognition fulfillment and return-to-plateau remain unproven on an exact package. 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: Commit and push the tested resident typed-fulfillment ownership cut, then package and authenticate that exact source with the persistent Starfire cache. Use only the authenticated repaired release on copied state for the mapped real admitted-model-direction active cognition endurance pass; prove pending-to-typed fulfillment, exact acknowledgement, cooldown plateau, bounded stores/artifacts, no external consequence, and clean direct-PID shutdown. Preserve active c005. Do not compact session/model/event/tool history until typed archived-session ownership exists.
active_subgoals:
- Prove Persona, Self, Eyes, Modeling, Imagination, Hands, Soul, Mind, Continuity, and nervous-system behavior individually.