From 706d0c3792ecc7abc379970d2831ab5982b1e1ad Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sun, 11 Oct 2026 15:22:22 +0200 Subject: [PATCH] Verse run: the driver labels a world ScopeChanged refusal ScopeMoved One fact, one label across lanes (ruling unsent-awaiting-row-is-awaiting). RefusalReason::ScopeMoved's doc names the unsent-awaiting state. Builds. Co-Authored-By: Claude Opus 5.5 --- crates/ghostlight/src/verse/run.rs | 16 +++++++++++----- crates/ghostlight/src/verse/run/tests.rs | 22 ++++++++++++++++++++++ 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/crates/ghostlight/src/verse/run.rs b/crates/ghostlight/src/verse/run.rs index 179653d..8fe9ba1 100644 --- a/crates/ghostlight/src/verse/run.rs +++ b/crates/ghostlight/src/verse/run.rs @@ -30,7 +30,8 @@ use crate::cover::{ Cell, CellId, Constituent, CoverBudget, CoverBudgetError, TickIndex, derive_cover, }; use crate::{ - AgencyGraph, CommandId, DecisionOpportunity, MailboxError, OperatorEvent, RenderPath, + AgencyGraph, CommandId, DecisionOpportunity, KernelError, MailboxError, OperatorEvent, + RenderPath, SubjectId, SubmitReceipt, TickMinutes, WorldId, WorldMailbox, WorldSnapshot, }; use chrono::Utc; @@ -94,10 +95,12 @@ pub enum RefusalReason { WorldRejected, /// The cell's subject no longer holds an opportunity. OpportunityGone, - /// The cell's in-flight work was bound to a scope that has since moved, - /// so it is refused before any inference. A cell whose command already - /// committed does not end this way: the controller answers it with its - /// receipt whatever the scope has done since. + /// The cell's work was bound to a scope that has since moved. Work still + /// reasoning is refused before any inference. Work whose submission body + /// was persisted but never sent is submitted and refused by the world with + /// `ScopeChanged`. A cell whose command already committed does not end + /// this way: the controller answers it with its receipt whatever the scope + /// has done since. ScopeMoved, } @@ -595,6 +598,9 @@ fn classify(error: &ControllerError) -> CellEnd { CellEnd::Budget } _ if error.requires_quarantine() => CellEnd::Fatal("controller_quarantined"), + ControllerError::World(KernelError::ScopeChanged { .. }) => { + CellEnd::Refused(RefusalReason::ScopeMoved) + } ControllerError::World(_) => CellEnd::Refused(RefusalReason::WorldRejected), ControllerError::NoOpportunity { .. } | ControllerError::AmbiguousOpportunity => { CellEnd::Refused(RefusalReason::OpportunityGone) diff --git a/crates/ghostlight/src/verse/run/tests.rs b/crates/ghostlight/src/verse/run/tests.rs index 82da589..e4bfe4e 100644 --- a/crates/ghostlight/src/verse/run/tests.rs +++ b/crates/ghostlight/src/verse/run/tests.rs @@ -979,6 +979,28 @@ fn an_error_ends_a_cell_as_the_run_must_treat_it() { )); } +/// One fact, one label: the world refusing a body whose scope moved is +/// `ScopeMoved`, the same label the controller's own refusal of in-flight work +/// carries, and not the catch-all `WorldRejected`. +#[tokio::test] +async fn a_world_refusal_for_a_moved_scope_is_scope_moved() { + let (_dir, verse) = Harness::fresh().await; + let opportunity = verse.mailbox.snapshot().await.unwrap().opportunities[0].clone(); + let moved = ControllerError::World(KernelError::ScopeChanged { + scope: opportunity.scope.clone(), + expected: opportunity.scope_digest.clone(), + actual: opportunity.scope_digest.clone(), + }); + assert!(matches!( + classify(&moved), + CellEnd::Refused(RefusalReason::ScopeMoved) + )); + assert!(matches!( + classify(&ControllerError::World(KernelError::AffordanceDenied)), + CellEnd::Refused(RefusalReason::WorldRejected) + )); +} + /// A recording port over the harness's call store for `sequence` under `cap`, /// and a runner on it. fn port_and_runner(