Odin: an unreadable projection file skips presences, not the catalog

Reading Idunn's projection once per catalog query (620efb8) made a
projection file that cannot be read refuse the whole catalog, where before
it failed each presence lookup and left the peer documents served. The
query now answers as if Idunn projected nothing, logged once per interval:
peer documents are served and presences skipped. Odin's own projection
check (require_own_projection) is unchanged and still retries or ends Odin
as before.

The new test restores file-level coverage: a projection that does not
decode, and one whose lock cannot be opened.

Soul finding 4.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-09-30 16:47:33 +02:00
commit 03f01ddba0
2 changed files with 41 additions and 4 deletions

View file

@ -213,7 +213,8 @@ impl CultCacheIdunnProjectionSource {
}
/// One reading of Idunn's projection file. Every lookup made against it is
/// answered from the same bytes.
/// answered from the same bytes. The default projects nothing.
#[derive(Default)]
pub struct IdunnProjectionSnapshot {
entries: Vec<CultCacheEnvelope>,
}

View file

@ -559,7 +559,10 @@ impl RuntimeState {
/// The catalog serves what is stored, one record at a time: a record that
/// does not decode, or whose incarnation's projection does not, is skipped
/// and logged, and is never a reason to refuse every other record. Idunn's
/// projection is read once per query. Odin's
/// projection is read once per query; a projection that cannot be read at
/// all is every presence's failure and no one else's, so the query is
/// answered as if Idunn projected nothing: peer documents are served and
/// presences skipped. Odin's
/// correlations are not part of the catalog: Idunn reads them from the
/// store file, and a target has one per incarnation, so keying them by
/// target would collide for the whole deploy window.
@ -568,8 +571,15 @@ impl RuntimeState {
query: &CultMeshRudpSnapshotQuery,
) -> Result<Vec<CultNetRawDocumentRecord>> {
let records = self.topology()?.store.records();
let projections =
CultCacheIdunnProjectionSource::new(&self.options.idunn_projection).snapshot()?;
let projections = CultCacheIdunnProjectionSource::new(&self.options.idunn_projection)
.snapshot()
.unwrap_or_else(|error| {
self.log_repeating(
"catalog skips every presence",
format!("Idunn's projection cannot be read: {error:#}"),
);
IdunnProjectionSnapshot::default()
});
let mut selected = BTreeMap::new();
for envelope in records.values() {
let document = match self.public_document(&projections, envelope) {
@ -2536,6 +2546,32 @@ mod tests {
Ok(())
}
/// A projection file that cannot be read at all, because it does not
/// decode or cannot be opened, skips every presence and nothing else: the
/// catalog still serves the peer documents.
#[test]
fn a_projection_file_that_cannot_be_read_skips_presences_not_the_catalog() -> Result<()> {
let faults: [fn(&Path) -> Result<()>; 2] = [
|projection| Ok(std::fs::write(projection, b"not a cultcache store")?),
|projection| Ok(std::fs::remove_file(sibling_lock_path(projection)?)?),
];
for fault in faults {
let mut odin = activated_odin()?;
odin.pass()?;
provider_put(&odin, "ghostlight.doc.v1", "doc-1", vec![1])?;
assert_eq!(
documents_of(&odin.catalog()?, GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA),
1,
"Odin's own presence is served while the projection reads"
);
fault(&odin.state.borrow().options.idunn_projection)?;
let catalog = odin.catalog()?;
assert_eq!(documents_of(&catalog, "ghostlight.doc.v1"), 1);
assert_eq!(documents_of(&catalog, GAMECULT_RUNTIME_PRESENCE_HEALTH_SCHEMA), 0);
}
Ok(())
}
/// Every failure to establish Odin's OWN authority ends Odin (temporary
/// rule, see `survive`), whatever shape the failure takes: an anchor that
/// does not decode or names another schema, an Expected Idunn no longer