Pin storeless reads by directory snapshot, not one mtime
Soul's Cut 1 finding F2: the two read pins only proved the seeded store
file's mtime was unchanged, so a store attached at a shadow path (every
read writing path.with_extension("shadow.cc")) survived all 156 tests.
state_cache_reads_without_writing_the_store and
persona_social_cache_reads_without_writing_the_store now snapshot every
directory entry (name, length, mtime) before and after the read, require
exactly the store and its lock file, and require the snapshot unchanged.
cultcache-rs at a0813c6 exposes no backing-store count on CultCache, so
the directory is the observable layer.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
parent
589e71c321
commit
00991c1b03
2 changed files with 30 additions and 2 deletions
|
|
@ -914,13 +914,27 @@ mod tests {
|
|||
.write(true)
|
||||
.open(&store)?
|
||||
.set_modified(past)?;
|
||||
let listing = || -> Result<Vec<(std::ffi::OsString, u64, std::time::SystemTime)>> {
|
||||
let mut entries = std::fs::read_dir(temp.path())?
|
||||
.map(|entry| {
|
||||
let entry = entry?;
|
||||
let metadata = entry.metadata()?;
|
||||
Ok((entry.file_name(), metadata.len(), metadata.modified()?))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
entries.sort();
|
||||
Ok(entries)
|
||||
};
|
||||
let before = listing()?;
|
||||
let names = before.iter().map(|entry| entry.0.clone()).collect::<Vec<_>>();
|
||||
assert_eq!(names, ["social.cc", "social.cc.lock"]);
|
||||
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);
|
||||
assert_eq!(listing()?, before, "a read attached or wrote a store");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2745,13 +2745,27 @@ mod pressure_replay_tests {
|
|||
.write(true)
|
||||
.open(&store)?
|
||||
.set_modified(past)?;
|
||||
let listing = || -> Result<Vec<(std::ffi::OsString, u64, std::time::SystemTime)>> {
|
||||
let mut entries = std::fs::read_dir(temp.path())?
|
||||
.map(|entry| {
|
||||
let entry = entry?;
|
||||
let metadata = entry.metadata()?;
|
||||
Ok((entry.file_name(), metadata.len(), metadata.modified()?))
|
||||
})
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
entries.sort();
|
||||
Ok(entries)
|
||||
};
|
||||
let before = listing()?;
|
||||
let names = before.iter().map(|entry| entry.0.clone()).collect::<Vec<_>>();
|
||||
assert_eq!(names, ["resident.cc", "resident.cc.lock"]);
|
||||
let reopened = state_cache(&store)?;
|
||||
assert!(
|
||||
reopened
|
||||
.get::<ResidentSelfState>(RESIDENT_SELF_STATE_KEY)?
|
||||
.is_some()
|
||||
);
|
||||
assert_eq!(std::fs::metadata(&store)?.modified()?, past);
|
||||
assert_eq!(listing()?, before, "a read attached or wrote a store");
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue