Pin that Self and Persona social cache reads never write their stores
The re-pin swapped load_envelope for put_envelope on the claim that each site's cache has no store attached, so put_envelope stays memory-only. No existing test observed that: attaching the store in state_cache left every resident_self test passing, because re-pushing the envelope just read rewrites identical bytes. Each test seeds its store, sets the file's modified time to a fixed past instant, reopens the cache and requires the time to be unchanged. Any push replaces the file through a staged rename, so attaching a store to state_cache or persona_social_cache now fails the matching test. The retirement-receipt site takes a snapshot slice with no path, so it cannot acquire a store without a signature change. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
8b52d02c79
commit
df82992c60
2 changed files with 58 additions and 0 deletions
|
|
@ -891,3 +891,36 @@ fn stable_pending_mention_id(
|
|||
fn now_iso() -> String {
|
||||
chrono::Utc::now().to_rfc3339()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn persona_social_cache_reads_without_writing_the_store() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("social.cc");
|
||||
let cache = persona_social_cache(&store)?;
|
||||
let head = PersonaSocialRetentionHeadDocument {
|
||||
head: PersonaConversationRetentionHead::default(),
|
||||
};
|
||||
SingleFileMessagePackBackingStore::new(&store).push(
|
||||
&cache
|
||||
.prepare_entry(PERSONA_SOCIAL_RETENTION_HEAD_KEY, &head)?
|
||||
.0,
|
||||
)?;
|
||||
let past = std::time::UNIX_EPOCH + std::time::Duration::from_secs(1_000_000_000);
|
||||
std::fs::File::options()
|
||||
.write(true)
|
||||
.open(&store)?
|
||||
.set_modified(past)?;
|
||||
let reopened = persona_social_cache(&store)?;
|
||||
assert_eq!(
|
||||
reopened
|
||||
.get::<PersonaSocialRetentionHeadDocument>(PERSONA_SOCIAL_RETENTION_HEAD_KEY)?,
|
||||
Some(head)
|
||||
);
|
||||
assert_eq!(std::fs::metadata(&store)?.modified()?, past);
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2730,6 +2730,31 @@ mod pressure_replay_tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn state_cache_reads_without_writing_the_store() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("resident.cc");
|
||||
let cache = state_cache(&store)?;
|
||||
SingleFileMessagePackBackingStore::new(&store).push(
|
||||
&cache
|
||||
.prepare_entry(RESIDENT_SELF_STATE_KEY, &ResidentSelfState::default())?
|
||||
.0,
|
||||
)?;
|
||||
let past = std::time::UNIX_EPOCH + std::time::Duration::from_secs(1_000_000_000);
|
||||
std::fs::File::options()
|
||||
.write(true)
|
||||
.open(&store)?
|
||||
.set_modified(past)?;
|
||||
let reopened = state_cache(&store)?;
|
||||
assert!(
|
||||
reopened
|
||||
.get::<ResidentSelfState>(RESIDENT_SELF_STATE_KEY)?
|
||||
.is_some()
|
||||
);
|
||||
assert_eq!(std::fs::metadata(&store)?.modified()?, past);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn configured_operator_pressure_replay_preserves_the_first_document() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
|
|
|
|||
Reference in a new issue