From 9fdad1fda89e76864ea4c9e708455ed94768fbd2 Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Tue, 3 Nov 2026 23:47:27 -0600 Subject: [PATCH 1/2] test(id): prove schedule fire joiner-visibility and ceiling refusal (#5239, #796 item 10-2) --- pkgs/id/src/world/tests.rs | 91 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/pkgs/id/src/world/tests.rs b/pkgs/id/src/world/tests.rs index a2af96f2a8..e92f609aba 100644 --- a/pkgs/id/src/world/tests.rs +++ b/pkgs/id/src/world/tests.rs @@ -5885,6 +5885,61 @@ mod schedule_tests { ); } + /// Item 10-2 (#796/#5239): a schedule test that sets a ceiling. + /// `schedule.at` is granted, but the world's capability ceiling excludes + /// it, so the use is refused (and counted) and nothing pends — the + /// grant itself is kept, so lifting the ceiling would restore it. + #[tokio::test] + async fn a_schedule_outside_the_ceiling_is_refused_and_pends_nothing() { + let (mut actor, _clock, token, journal) = + scheduling_actor("sched-ceiling", &["schedule.at"], false); + let (reply, response) = tokio::sync::oneshot::channel(); + actor + .handle(WorldCommand::SetCapsCeiling { + ceiling: vec!["time.now".to_owned()], + reply, + }) + .await; + let _ = response.await.unwrap().unwrap(); + actor.after_change().await; + assert!( + actor.core.ledger.is_granted("schedule.at"), + "the grant is kept under the ceiling" + ); + assert!( + !actor.core.ledger.effective().contains("schedule.at"), + "the ceiling excludes schedule.at from the effective set" + ); + ask( + &mut actor, + &token, + serde_json::json!({"requests": [ + {"id": "s1", "cap": "schedule.at", "args": {"id": "nap", "at": EPOCH_MS + 60_000}}, + ]}), + ) + .await; + assert_eq!( + schedule_result(&actor, "s1").unwrap()["error"], + "cap_denied" + ); + assert!( + actor.core.ledger.usage()["schedule.at"].denied > 0, + "{:?}", + actor.core.ledger.usage() + ); + assert!( + actor.core.schedules.is_empty(), + "a ceiling-refused schedule pends nothing" + ); + assert!( + journal + .entries() + .iter() + .all(|entry| !matches!(entry, JournalEntry::ScheduleSet { .. })), + "a ceiling-refused request journals no schedule set" + ); + } + #[tokio::test] async fn a_due_schedule_fires_once_and_the_program_receives_it() { let (mut actor, clock, token, journal) = @@ -5935,6 +5990,42 @@ mod schedule_tests { ); } + /// Item 10-2 (#796/#5239): a schedule fire never reaches joiners. + /// The fire is a host `System` event delivered to the program; a + /// joiner's catch-up page (`events_after`) must not carry it, while a + /// genuine participant event on the same page still comes through. + #[test] + fn a_schedule_fire_never_reaches_joiners_via_events_after() { + let mut core = world(8); + let (_, token) = core + .issue_capability("Ada", WorldScopes::GUEST, CapabilityBounds::default()) + .unwrap(); + // Positive control: a participant event is visible to joiners. + assert_eq!(core.input(&token, b"move").unwrap().sequence, 1); + // A delivered fire, retained as host events are, carrying the + // schedule-fired payload for schedule "nap". + let fire = WorldEvent { + sequence: 2, + participant_id: 0, + kind: WorldEventKind::System { + event: schedule_fired_event("nap", false), + }, + }; + core.sequence = fire.sequence; + core.events.push_back(fire); + let page = core.events_after(&token, 0).unwrap(); + assert_eq!( + page.events.len(), + 1, + "only the participant event reaches a joiner: {page:?}" + ); + assert!(matches!(page.events[0].kind, WorldEventKind::Input(_))); + assert!( + !format!("{page:?}").contains("nap"), + "the schedule fire leaked to a joiner via events_after" + ); + } + #[tokio::test] async fn a_cancelled_schedule_never_fires_and_an_unknown_id_says_false() { let (mut actor, clock, token, _journal) = From e4cb9ef2adec0bf5d8e476ee286389937135529b Mon Sep 17 00:00:00 2001 From: "developing-today[bot]" <5454422+developing-today[bot]@users.noreply.github.com> Date: Wed, 4 Nov 2026 01:03:54 -0600 Subject: [PATCH 2/2] test(id): fix the two #5239 proving tests assertions (test bugs, not production bugs) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First full run of the new tests (previous holder was cut off while compiling) failed both, and both failures are in the tests: (1) a_schedule_fire_never_reaches_joiners_via_events_after scanned the whole EventPage Debug for the schedule id nap, but nap is a substring of the field name needs_snapshot — the page itself was correct (only the participant Input event, fire filtered by project_event_for). Renamed the id to siesta and scan only page.events. (2) a_schedule_outside_the_ceiling_is_refused_and_pends_nothing asserted is_granted (allowed-and-granted, false under a ceiling by design) instead of the kept granted set, and expected cap_denied where the ledger refusal is outside_ceiling, which the actor returns verbatim. Both assertions corrected; the behaviors they prove (fire filtered from joiners; ceiling refusal pends nothing and counts a denial) hold in production code. Verified: cargo test -p id --lib schedule_tests — 21/21 pass. --- pkgs/id/src/world/tests.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pkgs/id/src/world/tests.rs b/pkgs/id/src/world/tests.rs index e92f609aba..18bfd205a5 100644 --- a/pkgs/id/src/world/tests.rs +++ b/pkgs/id/src/world/tests.rs @@ -5903,9 +5903,13 @@ mod schedule_tests { let _ = response.await.unwrap().unwrap(); actor.after_change().await; assert!( - actor.core.ledger.is_granted("schedule.at"), + actor.core.ledger.granted().contains("schedule.at"), "the grant is kept under the ceiling" ); + assert!( + !actor.core.ledger.is_granted("schedule.at"), + "is_granted is allowed-and-granted: false while the ceiling excludes it" + ); assert!( !actor.core.ledger.effective().contains("schedule.at"), "the ceiling excludes schedule.at from the effective set" @@ -5920,7 +5924,7 @@ mod schedule_tests { .await; assert_eq!( schedule_result(&actor, "s1").unwrap()["error"], - "cap_denied" + "outside_ceiling" ); assert!( actor.core.ledger.usage()["schedule.at"].denied > 0, @@ -6003,12 +6007,14 @@ mod schedule_tests { // Positive control: a participant event is visible to joiners. assert_eq!(core.input(&token, b"move").unwrap().sequence, 1); // A delivered fire, retained as host events are, carrying the - // schedule-fired payload for schedule "nap". + // schedule-fired payload for schedule "siesta" (an id that is + // not a substring of any EventPage field name — "nap" is one + // of needs_snapshot, which false-positives a whole-page scan). let fire = WorldEvent { sequence: 2, participant_id: 0, kind: WorldEventKind::System { - event: schedule_fired_event("nap", false), + event: schedule_fired_event("siesta", false), }, }; core.sequence = fire.sequence; @@ -6021,7 +6027,7 @@ mod schedule_tests { ); assert!(matches!(page.events[0].kind, WorldEventKind::Input(_))); assert!( - !format!("{page:?}").contains("nap"), + !format!("{:?}", page.events).contains("siesta"), "the schedule fire leaked to a joiner via events_after" ); }