Bound coordinator receipt history
This commit is contained in:
parent
7001940aeb
commit
16c4b19f73
8 changed files with 441 additions and 12 deletions
|
|
@ -11,14 +11,15 @@ use epiphany_core::{
|
|||
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,
|
||||
prepare_resident_self_launch, publish_resident_provider_readiness,
|
||||
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_resident_self_lifecycles, validate_persona_feedback_store_separation,
|
||||
retain_coordinator_run_receipts, retain_resident_self_lifecycles,
|
||||
validate_persona_feedback_store_separation,
|
||||
validate_resident_self_store_separation, verify_resident_self_grant_fulfillment,
|
||||
};
|
||||
use serde_json::json;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::{BTreeMap, BTreeSet};
|
||||
use std::env;
|
||||
use std::path::PathBuf;
|
||||
use std::process::{Child, Command};
|
||||
|
|
@ -76,6 +77,7 @@ fn main() -> Result<()> {
|
|||
match args.command {
|
||||
CommandKind::Once => {
|
||||
let outcome = cycle(&args, &mut state, &mut ports, false)?;
|
||||
retain_runtime_receipts(&args, &state)?;
|
||||
retain_resident_self_lifecycles(
|
||||
&args.state_store,
|
||||
args.retained_closed_lifecycles,
|
||||
|
|
@ -92,6 +94,7 @@ fn main() -> Result<()> {
|
|||
loop {
|
||||
let shutting_down = shutdown_requested.load(Ordering::SeqCst);
|
||||
let outcome = cycle(&args, &mut state, &mut ports, shutting_down)?;
|
||||
retain_runtime_receipts(&args, &state)?;
|
||||
retain_resident_self_lifecycles(
|
||||
&args.state_store,
|
||||
args.retained_closed_lifecycles,
|
||||
|
|
@ -118,6 +121,33 @@ fn main() -> Result<()> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
fn retain_runtime_receipts(args: &Args, state: &ResidentSelfState) -> Result<()> {
|
||||
if !runtime_receipt_retention_allowed(
|
||||
state.active_turn.is_some(),
|
||||
state.prepared_launch.is_some(),
|
||||
) {
|
||||
return Ok(());
|
||||
}
|
||||
let mut preserved = pending_resident_self_acks(&args.state_store)?
|
||||
.into_iter()
|
||||
.map(|ack| ack.coordinator_receipt_id)
|
||||
.collect::<BTreeSet<_>>();
|
||||
if let Some(receipt_id) = &state.last_coordinator_receipt_id {
|
||||
preserved.insert(receipt_id.clone());
|
||||
}
|
||||
retain_coordinator_run_receipts(
|
||||
&args.policy.runtime_store,
|
||||
args.retained_coordinator_receipts,
|
||||
&preserved,
|
||||
&Utc::now().to_rfc3339(),
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn runtime_receipt_retention_allowed(has_active_turn: bool, has_prepared_launch: bool) -> bool {
|
||||
!has_active_turn && !has_prepared_launch
|
||||
}
|
||||
|
||||
fn publish_self_readiness(args: &Args) -> Result<()> {
|
||||
let process = capture_process_instance(std::process::id())?;
|
||||
publish_resident_provider_readiness(
|
||||
|
|
@ -423,6 +453,7 @@ struct Args {
|
|||
heartbeat_store: PathBuf,
|
||||
provider_freshness_seconds: u64,
|
||||
retained_closed_lifecycles: usize,
|
||||
retained_coordinator_receipts: usize,
|
||||
persona_feedback_source_store: PathBuf,
|
||||
persona_feedback_store: PathBuf,
|
||||
bifrost_feedback_trust_anchor: PathBuf,
|
||||
|
|
@ -527,6 +558,9 @@ impl Args {
|
|||
retained_closed_lifecycles: u64v("--retained-closed-lifecycles", 256)?
|
||||
.try_into()
|
||||
.context("--retained-closed-lifecycles exceeds platform size")?,
|
||||
retained_coordinator_receipts: u64v("--retained-coordinator-receipts", 256)?
|
||||
.try_into()
|
||||
.context("--retained-coordinator-receipts exceeds platform size")?,
|
||||
persona_feedback_source_store: path("--persona-feedback-source-store")?,
|
||||
persona_feedback_store: path("--persona-feedback-store")?,
|
||||
bifrost_feedback_trust_anchor: path("--bifrost-feedback-trust-anchor")?,
|
||||
|
|
@ -738,4 +772,12 @@ mod brake_tests {
|
|||
assert!(touched.get());
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_receipt_retention_refuses_active_or_prepared_launch_authority() {
|
||||
assert!(runtime_receipt_retention_allowed(false, false));
|
||||
assert!(!runtime_receipt_retention_allowed(true, false));
|
||||
assert!(!runtime_receipt_retention_allowed(false, true));
|
||||
assert!(!runtime_receipt_retention_allowed(true, true));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -973,6 +973,7 @@ pub use resident_self::*;
|
|||
pub use runtime_spine::COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION;
|
||||
pub use runtime_spine::COORDINATOR_RUN_RECEIPT_TYPE;
|
||||
pub use runtime_spine::EpiphanyCoordinatorRunReceipt;
|
||||
pub use runtime_spine::EpiphanyCoordinatorRunReceiptRetentionHead;
|
||||
pub use runtime_spine::EpiphanyJobInterruptRequest;
|
||||
pub use runtime_spine::EpiphanyJobInterruptResult;
|
||||
pub use runtime_spine::EpiphanyJobLaunchRequest;
|
||||
|
|
@ -1047,6 +1048,7 @@ pub use runtime_spine::operator_repo_frontier_plan_review_is_current;
|
|||
pub use runtime_spine::pending_repo_frontier_plan_reviews;
|
||||
pub use runtime_spine::plan_runtime_spine_heartbeat_launch;
|
||||
pub use runtime_spine::prepare_runtime_spine_heartbeat_job;
|
||||
pub use runtime_spine::retain_coordinator_run_receipts;
|
||||
pub use runtime_spine::promote_autonomous_direction_options_for_modeling;
|
||||
pub use runtime_spine::put_continuity_recovery_receipt;
|
||||
pub use runtime_spine::put_coordinator_run_receipt;
|
||||
|
|
|
|||
|
|
@ -165,6 +165,9 @@ pub const RUNTIME_REORIENT_WORKER_RESULT_TYPE: &str = "epiphany.runtime.reorient
|
|||
pub const RUNTIME_JOB_RESULT_TYPE: &str = "epiphany.runtime.job_result";
|
||||
pub const RUNTIME_EVENT_TYPE: &str = "epiphany.runtime.event";
|
||||
pub const COORDINATOR_RUN_RECEIPT_TYPE: &str = "epiphany.coordinator_run_receipt.v0";
|
||||
pub const COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_SCHEMA_VERSION: &str =
|
||||
"epiphany.coordinator_run_receipt_retention_head.v0";
|
||||
pub const COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_KEY: &str = "coordinator-run-receipt-retention";
|
||||
pub const OPENAI_ADAPTER_STATUS_TYPE: &str = "epiphany.openai_adapter_status.v0";
|
||||
pub const OPENAI_MODEL_REQUEST_TYPE: &str = "epiphany.openai_model_request.v0";
|
||||
pub const OPENAI_MODEL_STREAM_EVENT_TYPE: &str = "epiphany.openai_model_stream_event.v0";
|
||||
|
|
@ -683,6 +686,28 @@ pub struct EpiphanyCoordinatorRunReceipt {
|
|||
pub resident_executable_digest: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.coordinator_run_receipt_retention_head.v0",
|
||||
schema = "EpiphanyCoordinatorRunReceiptRetentionHead"
|
||||
)]
|
||||
pub struct EpiphanyCoordinatorRunReceiptRetentionHead {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub revision: u64,
|
||||
#[cultcache(key = 2)]
|
||||
pub retired_receipt_count: u64,
|
||||
#[cultcache(key = 3)]
|
||||
pub retired_status_counts: BTreeMap<String, u64>,
|
||||
#[cultcache(key = 4)]
|
||||
pub retired_chain_digest: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub retained_at: String,
|
||||
#[cultcache(key = 6, default)]
|
||||
pub private_state_exposed: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyRuntimeSessionStatus {
|
||||
|
|
@ -965,6 +990,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
cache.register_entry_type::<EpiphanyRuntimeJobResult>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeEvent>()?;
|
||||
cache.register_entry_type::<EpiphanyCoordinatorRunReceipt>()?;
|
||||
cache.register_entry_type::<EpiphanyCoordinatorRunReceiptRetentionHead>()?;
|
||||
cache.register_entry_type::<MindGatewayReview>()?;
|
||||
cache.register_entry_type::<MindStateCommitReceipt>()?;
|
||||
cache.register_entry_type::<EyesEvidencePacket>()?;
|
||||
|
|
@ -8652,6 +8678,136 @@ pub fn coordinator_run_receipts(
|
|||
cache.get_all::<EpiphanyCoordinatorRunReceipt>()
|
||||
}
|
||||
|
||||
pub fn retain_coordinator_run_receipts(
|
||||
store_path: impl AsRef<Path>,
|
||||
retain_recent: usize,
|
||||
preserve_receipt_ids: &BTreeSet<String>,
|
||||
retained_at: &str,
|
||||
) -> Result<Option<EpiphanyCoordinatorRunReceiptRetentionHead>> {
|
||||
chrono::DateTime::parse_from_rfc3339(retained_at)
|
||||
.map_err(|error| anyhow!("coordinator receipt retention timestamp is invalid: {error}"))?;
|
||||
let store_path = store_path.as_ref();
|
||||
let mut cache = runtime_spine_cache(store_path)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
let mut receipts = cache.get_all::<EpiphanyCoordinatorRunReceipt>()?;
|
||||
let created_at_by_receipt = receipts
|
||||
.iter()
|
||||
.map(|receipt| {
|
||||
chrono::DateTime::parse_from_rfc3339(&receipt.created_at)
|
||||
.map(|created_at| (receipt.receipt_id.clone(), created_at))
|
||||
.map_err(|error| {
|
||||
anyhow!(
|
||||
"coordinator receipt {:?} has invalid created_at: {error}",
|
||||
receipt.receipt_id
|
||||
)
|
||||
})
|
||||
})
|
||||
.collect::<Result<BTreeMap<_, _>>>()?;
|
||||
receipts.sort_by(|left, right| {
|
||||
created_at_by_receipt[&left.receipt_id]
|
||||
.cmp(&created_at_by_receipt[&right.receipt_id])
|
||||
.then(left.receipt_id.cmp(&right.receipt_id))
|
||||
});
|
||||
let keep_recent = retain_recent.max(1);
|
||||
let recent_ids = receipts
|
||||
.iter()
|
||||
.rev()
|
||||
.take(keep_recent)
|
||||
.map(|receipt| receipt.receipt_id.as_str())
|
||||
.collect::<BTreeSet<_>>();
|
||||
let retired = receipts
|
||||
.iter()
|
||||
.filter(|receipt| {
|
||||
!recent_ids.contains(receipt.receipt_id.as_str())
|
||||
&& !preserve_receipt_ids.contains(&receipt.receipt_id)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if retired.is_empty() {
|
||||
return Ok(None);
|
||||
}
|
||||
|
||||
let prior = cache.get::<EpiphanyCoordinatorRunReceiptRetentionHead>(
|
||||
COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_KEY,
|
||||
)?;
|
||||
if let Some(head) = &prior {
|
||||
if head.schema_version != COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_SCHEMA_VERSION
|
||||
|| head.private_state_exposed
|
||||
|| !head.retired_chain_digest.starts_with("sha256:")
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"coordinator run receipt retention head is invalid"
|
||||
));
|
||||
}
|
||||
}
|
||||
let snapshot = cache.snapshot_envelopes();
|
||||
let mut deletions = retired
|
||||
.iter()
|
||||
.map(|receipt| {
|
||||
snapshot
|
||||
.iter()
|
||||
.find(|entry| {
|
||||
entry.r#type == EpiphanyCoordinatorRunReceipt::TYPE
|
||||
&& entry.key == receipt.receipt_id
|
||||
})
|
||||
.cloned()
|
||||
.ok_or_else(|| anyhow!("coordinator receipt lost its exact envelope"))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
deletions.sort_by(|left, right| {
|
||||
left.r#type
|
||||
.cmp(&right.r#type)
|
||||
.then(left.key.cmp(&right.key))
|
||||
});
|
||||
let mut status_counts = prior
|
||||
.as_ref()
|
||||
.map(|head| head.retired_status_counts.clone())
|
||||
.unwrap_or_default();
|
||||
for receipt in &retired {
|
||||
*status_counts.entry(receipt.status.clone()).or_default() += 1;
|
||||
}
|
||||
let mut digest = Sha256::new();
|
||||
let prior_digest = prior
|
||||
.as_ref()
|
||||
.map(|head| head.retired_chain_digest.as_str())
|
||||
.unwrap_or("coordinator-run-receipt-retention-root");
|
||||
digest.update((prior_digest.len() as u64).to_le_bytes());
|
||||
digest.update(prior_digest.as_bytes());
|
||||
for entry in &deletions {
|
||||
for bytes in [
|
||||
entry.r#type.as_bytes(),
|
||||
entry.key.as_bytes(),
|
||||
entry.payload.as_slice(),
|
||||
] {
|
||||
digest.update((bytes.len() as u64).to_le_bytes());
|
||||
digest.update(bytes);
|
||||
}
|
||||
}
|
||||
let head = EpiphanyCoordinatorRunReceiptRetentionHead {
|
||||
schema_version: COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_SCHEMA_VERSION.into(),
|
||||
revision: prior.as_ref().map_or(1, |head| head.revision + 1),
|
||||
retired_receipt_count: prior.as_ref().map_or(retired.len() as u64, |head| {
|
||||
head.retired_receipt_count + retired.len() as u64
|
||||
}),
|
||||
retired_status_counts: status_counts,
|
||||
retired_chain_digest: format!("sha256:{:x}", digest.finalize()),
|
||||
retained_at: retained_at.into(),
|
||||
private_state_exposed: false,
|
||||
};
|
||||
let (replacement, _) = cache.prepare_entry(
|
||||
COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_KEY,
|
||||
&head,
|
||||
)?;
|
||||
if !runtime_spine_backing_store(store_path)?
|
||||
.replace_and_delete_if_snapshot_unchanged(&snapshot, vec![replacement], &deletions)?
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"coordinator run receipt retention lost its snapshot fence"
|
||||
));
|
||||
}
|
||||
Ok(Some(head))
|
||||
}
|
||||
|
||||
pub fn complete_runtime_job(
|
||||
store_path: impl AsRef<Path>,
|
||||
options: RuntimeSpineJobResultOptions,
|
||||
|
|
@ -13680,6 +13836,180 @@ pub(crate) mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coordinator_run_receipt_retention_preserves_authority_and_cannot_resurrect_work(
|
||||
) -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
&store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-retention-test".to_string(),
|
||||
display_name: "Epiphany Retention Test".to_string(),
|
||||
created_at: "2026-05-06T00:00:00Z".to_string(),
|
||||
},
|
||||
)?;
|
||||
for (index, status) in ["planned", "completed", "failed", "completed"]
|
||||
.into_iter()
|
||||
.enumerate()
|
||||
{
|
||||
let ordinal = index + 1;
|
||||
put_coordinator_run_receipt(
|
||||
&store,
|
||||
&EpiphanyCoordinatorRunReceipt {
|
||||
schema_version: COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: format!("receipt-{ordinal}"),
|
||||
session_id: "session-1".to_string(),
|
||||
thread_id: "thread-1".to_string(),
|
||||
mode: "default".to_string(),
|
||||
status: status.to_string(),
|
||||
final_action: "manualRegather".to_string(),
|
||||
final_reason: None,
|
||||
step_count: ordinal as u64,
|
||||
created_at: format!("2026-05-06T00:0{ordinal}:00Z"),
|
||||
model_provider: None,
|
||||
runtime_store: store.display().to_string(),
|
||||
artifact_refs: Vec::new(),
|
||||
sealed_artifact_refs: Vec::new(),
|
||||
metadata: BTreeMap::new(),
|
||||
resident_grant_id: None,
|
||||
resident_launch_digest: None,
|
||||
resident_policy_digest: None,
|
||||
resident_argv_digest: None,
|
||||
resident_objective_digest: None,
|
||||
resident_release_commit: None,
|
||||
resident_release_manifest_digest: None,
|
||||
resident_executable_digest: None,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
|
||||
let preserved = BTreeSet::from(["receipt-1".to_string()]);
|
||||
let mut before_cache = runtime_spine_cache(&store)?;
|
||||
before_cache.pull_all_backing_stores()?;
|
||||
let unrelated_before = before_cache
|
||||
.snapshot_envelopes()
|
||||
.into_iter()
|
||||
.filter(|entry| entry.r#type != EpiphanyCoordinatorRunReceipt::TYPE)
|
||||
.collect::<Vec<_>>();
|
||||
let head = retain_coordinator_run_receipts(
|
||||
&store,
|
||||
1,
|
||||
&preserved,
|
||||
"2026-05-06T00:10:00Z",
|
||||
)?
|
||||
.expect("two receipts should be retired");
|
||||
assert_eq!(head.revision, 1);
|
||||
assert_eq!(head.retired_receipt_count, 2);
|
||||
assert_eq!(
|
||||
head.retired_status_counts,
|
||||
BTreeMap::from([("completed".to_string(), 1), ("failed".to_string(), 1)])
|
||||
);
|
||||
assert!(head.retired_chain_digest.starts_with("sha256:"));
|
||||
|
||||
let receipts = coordinator_run_receipts(&store)?;
|
||||
assert_eq!(
|
||||
receipts
|
||||
.iter()
|
||||
.map(|receipt| receipt.receipt_id.as_str())
|
||||
.collect::<BTreeSet<_>>(),
|
||||
BTreeSet::from(["receipt-1", "receipt-4"])
|
||||
);
|
||||
let mut cache = runtime_spine_cache(&store)?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
let unrelated_after = cache
|
||||
.snapshot_envelopes()
|
||||
.into_iter()
|
||||
.filter(|entry| {
|
||||
entry.r#type != EpiphanyCoordinatorRunReceipt::TYPE
|
||||
&& entry.r#type != EpiphanyCoordinatorRunReceiptRetentionHead::TYPE
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
assert_eq!(unrelated_after, unrelated_before);
|
||||
assert!(
|
||||
cache
|
||||
.get::<EpiphanyCoordinatorRunReceipt>(
|
||||
COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_KEY,
|
||||
)?
|
||||
.is_none(),
|
||||
"the retention head must not deserialize as runnable receipt authority"
|
||||
);
|
||||
assert_eq!(
|
||||
cache
|
||||
.get::<EpiphanyCoordinatorRunReceiptRetentionHead>(
|
||||
COORDINATOR_RUN_RECEIPT_RETENTION_HEAD_KEY,
|
||||
)?
|
||||
.as_ref(),
|
||||
Some(&head)
|
||||
);
|
||||
assert!(
|
||||
retain_coordinator_run_receipts(
|
||||
&store,
|
||||
1,
|
||||
&preserved,
|
||||
"2026-05-06T00:11:00Z",
|
||||
)?
|
||||
.is_none(),
|
||||
"a stable retained set must not rewrite the head"
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn coordinator_run_receipt_retention_keeps_newest_when_window_is_zero() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
initialize_runtime_spine(
|
||||
&store,
|
||||
RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-zero-window-test".to_string(),
|
||||
display_name: "Epiphany Zero Window Test".to_string(),
|
||||
created_at: "2026-05-06T00:00:00Z".to_string(),
|
||||
},
|
||||
)?;
|
||||
for ordinal in 1..=2 {
|
||||
put_coordinator_run_receipt(
|
||||
&store,
|
||||
&EpiphanyCoordinatorRunReceipt {
|
||||
schema_version: COORDINATOR_RUN_RECEIPT_SCHEMA_VERSION.to_string(),
|
||||
receipt_id: format!("receipt-{ordinal}"),
|
||||
session_id: "session-1".to_string(),
|
||||
thread_id: "thread-1".to_string(),
|
||||
mode: "default".to_string(),
|
||||
status: "completed".to_string(),
|
||||
final_action: "manualRegather".to_string(),
|
||||
final_reason: None,
|
||||
step_count: ordinal,
|
||||
created_at: format!("2026-05-06T00:0{ordinal}:00Z"),
|
||||
model_provider: None,
|
||||
runtime_store: store.display().to_string(),
|
||||
artifact_refs: Vec::new(),
|
||||
sealed_artifact_refs: Vec::new(),
|
||||
metadata: BTreeMap::new(),
|
||||
resident_grant_id: None,
|
||||
resident_launch_digest: None,
|
||||
resident_policy_digest: None,
|
||||
resident_argv_digest: None,
|
||||
resident_objective_digest: None,
|
||||
resident_release_commit: None,
|
||||
resident_release_manifest_digest: None,
|
||||
resident_executable_digest: None,
|
||||
},
|
||||
)?;
|
||||
}
|
||||
retain_coordinator_run_receipts(
|
||||
&store,
|
||||
0,
|
||||
&BTreeSet::new(),
|
||||
"2026-05-06T00:10:00Z",
|
||||
)?
|
||||
.expect("the older receipt should be retired");
|
||||
let receipts = coordinator_run_receipts(&store)?;
|
||||
assert_eq!(receipts.len(), 1);
|
||||
assert_eq!(receipts[0].receipt_id, "receipt-2");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_spine_derives_tool_invocation_statuses() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
|
|
|
|||
|
|
@ -53,6 +53,28 @@ impl RuntimeSpineBackingStore {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn replace_and_delete_if_snapshot_unchanged(
|
||||
&self,
|
||||
expected_snapshot: &[CultCacheEnvelope],
|
||||
replacements: Vec<CultCacheEnvelope>,
|
||||
deletions: &[CultCacheEnvelope],
|
||||
) -> Result<bool> {
|
||||
match self.selected()? {
|
||||
SelectedBackingStore::Snapshot(store) => store
|
||||
.replace_and_delete_if_snapshot_unchanged(
|
||||
expected_snapshot,
|
||||
replacements,
|
||||
deletions,
|
||||
),
|
||||
SelectedBackingStore::Keyed(store) => store
|
||||
.replace_and_delete_if_snapshot_unchanged(
|
||||
expected_snapshot,
|
||||
replacements,
|
||||
deletions,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl CacheBackingStore for RuntimeSpineBackingStore {
|
||||
|
|
|
|||
|
|
@ -2105,14 +2105,16 @@ work.
|
|||
stores only the latest receipt identity and terminal acknowledgements may
|
||||
reference an exact receipt.
|
||||
- **Inputs:** receipts older than the retained frontier and unreferenced by
|
||||
current resident state, pending acknowledgements, accepted coordinator
|
||||
state, or recovery paths.
|
||||
the configurable newest window or explicit IDs supplied from current
|
||||
resident state and pending acknowledgements. Retention refuses prepared or
|
||||
active launch authority.
|
||||
- **Outputs:** a typed accumulator preserving terminal counts/digests without
|
||||
pretending to be a runnable receipt.
|
||||
- **Forbidden writers:** resident retention cannot delete runtime receipts;
|
||||
runtime compaction cannot guess that cross-store references are dead.
|
||||
- **Deletion line:** no coordinator receipt retirement until the cross-store
|
||||
reference set and crash-recovery readers are source-grounded and tested.
|
||||
- **Deletion line:** runtime replaces the singleton head and deletes exact old
|
||||
receipt envelopes in one full-snapshot-fenced transaction. Unknown runtime
|
||||
rows remain byte-identical.
|
||||
|
||||
### Supervisor stdout/stderr
|
||||
|
||||
|
|
@ -2208,5 +2210,20 @@ 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.
|
||||
|
||||
The next bounded implementation is coordinator receipt accumulation only. It
|
||||
must not pretend to solve runtime session/model/event retention.
|
||||
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
|
||||
from pending terminal acknowledgements and `last_coordinator_receipt_id` before
|
||||
resident lifecycle retirement; it does not write or delete runtime rows
|
||||
directly. Retention is forbidden while active-turn or prepared-launch authority
|
||||
exists, closing the interval where a child may have written its terminal
|
||||
receipt but Self has not yet observed exit. The default window is 256 and the
|
||||
newest receipt survives even when the configured window is zero. CultCache's production non-owning redb handle
|
||||
now exposes the same fenced compaction primitive as the snapshot and owned-redb
|
||||
backends. Unit tests prove stale-snapshot refusal, explicit-ID preservation,
|
||||
zero-window newest preservation, stable replay, and that the head cannot
|
||||
deserialize or enumerate as runnable coordinator receipt authority.
|
||||
|
||||
The source still requires an exact authenticated package and copied-state
|
||||
production proof. It does not pretend to solve runtime
|
||||
session/model/event/tool retention.
|
||||
|
|
|
|||
|
|
@ -1094,3 +1094,19 @@ The accumulator must not enumerate as a receipt or satisfy resident completion.
|
|||
Session/job/event/model/tool retention remains forbidden until typed archived
|
||||
session ownership closes tool follow-up, review, recovery, and accepted-frontier
|
||||
references.
|
||||
|
||||
The source implementation is now complete but not yet packaged. Runtime owns a
|
||||
typed cumulative count/digest head and exact receipt deletion behind one
|
||||
full-snapshot fence. Resident Self invokes it after each cycle, before resident
|
||||
lifecycle retirement, with a default-256 window and explicit preservation of
|
||||
every pending terminal acknowledgement plus `last_coordinator_receipt_id`.
|
||||
Even a configured zero window retains the newest receipt. The head has a
|
||||
distinct CultCache type and cannot enumerate as `EpiphanyCoordinatorRunReceipt`.
|
||||
Retention refuses to run while active-turn or prepared-launch authority exists,
|
||||
so a child cannot write its terminal receipt during the pre-exit observation
|
||||
window and have a small retention window retire it before completion scanning.
|
||||
CultCache `9cae2779` supplies the same atomic replace/delete primitive to the
|
||||
production non-owning redb handle; its concurrent-insert refusal test passes.
|
||||
Twenty resident tests, seven swarm tests, and two coordinator-retention tests
|
||||
pass. Next commit and package this exact source, then prove it on copied state;
|
||||
active c005 remains untouched.
|
||||
|
|
|
|||
|
|
@ -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 run receipts and broader semantic/runtime histories remain unbounded and require owner-specific typed non-authority accumulators plus exact reference-aware deletion. Supervisor stdout/stderr are truncated only at launch and unbounded during a long-lived process; the fatal log is append-only. 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: Implement runtime-owned coordinator receipt accumulation only: preserve the newest receipt plus a configurable historical window and explicit cross-store IDs; atomically replace one non-authority head while deleting exact old receipts; prove the head cannot satisfy resident completion. Do not compact session/model/event/tool history until typed archived-session ownership exists. Then settle supervisor log ownership, run packaged Heartbeat retention, and measure idle/active endurance.
|
||||
unresolved_authority: Coordinator receipt retention is implemented and locally proven but still requires exact authenticated packaging and copied-state production proof. Broader semantic/runtime histories remain unbounded pending a typed archived-session owner. Supervisor stdout/stderr are truncated only at launch and unbounded during a long-lived process; the fatal log is append-only. 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 package the exact coordinator receipt retention source, then exercise packaged Self only on copied state and prove the typed accumulator cannot create pending work, satisfy resident completion, or resurrect a turn. Preserve active c005. After acceptance, settle supervisor log ownership, audit packaged Heartbeat retention, and measure idle/active endurance. 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.
|
||||
|
|
|
|||
2
vendor/cultcache-rs
vendored
2
vendor/cultcache-rs
vendored
|
|
@ -1 +1 @@
|
|||
Subproject commit fecc17c93dafb942e54c797286e92218f0ceae1d
|
||||
Subproject commit 9cae27799232db29b33ef19fabafffcce1a996e1
|
||||
Reference in a new issue