diff --git a/pkgs/id/crates/id-worlds/src/world_owner_report.rs b/pkgs/id/crates/id-worlds/src/world_owner_report.rs index c0b22f0734..97267482d3 100644 --- a/pkgs/id/crates/id-worlds/src/world_owner_report.rs +++ b/pkgs/id/crates/id-worlds/src/world_owner_report.rs @@ -76,7 +76,9 @@ impl UnavailableReason { pub const fn describe(self) -> &'static str { match self { Self::JoinTimeNotRecorded => "the journal does not record when anyone joined", - Self::RevokeTimeNotRecorded => "the journal does not record when anyone was revoked", + Self::RevokeTimeNotRecorded => { + "the journal does not record when all revocations occurred" + } Self::NoJoins => "no one has joined yet", Self::LiveStateNotProvided => "no live snapshot (the world is not running here)", Self::ProgramRunsNotRecorded => "program runs are not recorded by this journal", @@ -242,7 +244,7 @@ pub struct JoinsSection { /// Joins whose entry carries no time (issued before times were /// recorded). pub untimed: u64, - /// Revokes inside the requested window, counting those with a time. + /// Revokes inside the requested window; unavailable if any revoke lacks a time. pub revoked_in_window: Measured, /// Revoked participants whose revoke carries no time. pub revoked_untimed: u64, @@ -667,7 +669,7 @@ pub fn project( .values() .filter(|f| f.revoked && f.revoked_at.is_some()) .count() as u64; - let revoked_in_window = if revoked > 0 && revoked_timed == 0 { + let revoked_in_window = if revoked_timed < revoked { Measured::Unavailable(UnavailableReason::RevokeTimeNotRecorded) } else { Measured::Known( diff --git a/pkgs/id/crates/id-worlds/src/world_owner_report_tests.rs b/pkgs/id/crates/id-worlds/src/world_owner_report_tests.rs index c8f9bbd67a..73eda78855 100644 --- a/pkgs/id/crates/id-worlds/src/world_owner_report_tests.rs +++ b/pkgs/id/crates/id-worlds/src/world_owner_report_tests.rs @@ -536,6 +536,52 @@ fn timed_joins_give_exact_window_counts_and_since() { assert_eq!(report.joins.in_window, Measured::Known(1)); } +// #12041 oracle: an untimed revocation may belong to any requested window, +// so a timed subset (including zero) cannot establish a complete count. +#[test] +fn mixed_revocation_times_never_report_a_complete_window_count() { + let v = crate::world::JOURNAL_VERSION_JOIN_TIMES; + for timed_at in [INSIDE, BEFORE, request().window.to_unix_ms] { + let report = run(&jsonl(&[ + header(v), + issued(1, None, None), + issued_at(2, BEFORE), + revoked(1), + revoked_at(2, timed_at), + ])) + .unwrap(); + assert_eq!(report.joins.revoked, 2); + assert_eq!(report.joins.revoked_untimed, 1); + assert_eq!( + report.joins.revoked_in_window, + Measured::Unavailable(UnavailableReason::RevokeTimeNotRecorded), + "timed revocation at {timed_at} does not date the untimed one" + ); + } +} + +#[test] +fn complete_revocation_times_keep_known_window_counts() { + let v = crate::world::JOURNAL_VERSION_JOIN_TIMES; + let window = request().window; + let report = run(&jsonl(&[ + header(v), + issued_at(1, BEFORE), + issued_at(2, BEFORE), + issued_at(3, BEFORE), + revoked_at(1, BEFORE), + revoked_at(2, window.from_unix_ms), + revoked_at(3, window.to_unix_ms), + ])) + .unwrap(); + assert_eq!(report.joins.revoked_in_window, Measured::Known(1)); + assert_eq!(report.joins.revoked_untimed, 0); + // Untimed joins are irrelevant when nobody has been revoked. + let none = run(&jsonl(&[header(v), issued(1, None, None)])).unwrap(); + assert_eq!(none.joins.revoked_in_window, Measured::Known(0)); + assert_eq!(none.joins.revoked_untimed, 0); +} + #[test] fn joins_from_before_the_upgrade_stay_untimed_and_mark_the_window_incomplete() { let v = crate::world::JOURNAL_VERSION_JOIN_TIMES;