Aetherlight AL2b-2a: pin the reduce gate and the title clause
A non-Play caller's broken patch and ungranted act are Unauthorized, so dropping require_play from reduce fails a test (it was not equivalent: the refusal would leak world structure). A forged empty or padded stored title is Corrupt. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
105632df25
commit
9df34ea28a
2 changed files with 62 additions and 0 deletions
|
|
@ -2302,6 +2302,30 @@ mod custody_tests {
|
|||
);
|
||||
}
|
||||
|
||||
/// The title clause of the shape check refuses an empty title and a
|
||||
/// noncanonical one, each on its own.
|
||||
#[test]
|
||||
fn a_forged_empty_or_padded_title_is_corrupt() {
|
||||
use crate::tests::{auth_principal, creation, owner};
|
||||
|
||||
let directory = tempfile::tempdir().unwrap();
|
||||
let (kernel, _) = WorldKernel::create(
|
||||
directory.path().join("world.cc"),
|
||||
creation(CommandId::new(), "Titled"),
|
||||
&auth_principal(owner()),
|
||||
)
|
||||
.unwrap();
|
||||
verify_state_shape(&kernel.state).expect("a canonical title passes");
|
||||
for title in ["", " ", " Titled", "Titled "] {
|
||||
let mut forged = kernel.state.clone();
|
||||
forged.title = title.into();
|
||||
assert!(
|
||||
matches!(verify_state_shape(&forged), Err(JournalError::Corrupt(_))),
|
||||
"title {title:?} passed the shape check"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/// A grant row is a verb list for a live subject: each clause of the shape
|
||||
/// check is pinned on `verify_state_shape` directly, one forged state per
|
||||
/// clause, so deleting any one of them fails a case.
|
||||
|
|
|
|||
|
|
@ -12602,6 +12602,44 @@ mod agency_tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// The gate sits at the top of `reduce`, so a non-Play caller learns
|
||||
/// nothing about the world through a refusal: a patch that would be
|
||||
/// rejected for naming an unknown subject, and an act the actor has no
|
||||
/// grant for, both come back Unauthorized.
|
||||
#[test]
|
||||
fn a_non_play_caller_is_refused_before_the_world_is_read() {
|
||||
let (_directory, _path, mut kernel) = world("Blind");
|
||||
let snapshot = kernel.snapshot().unwrap();
|
||||
let persona = subject_by_mode(&kernel.state, ControllerMode::NarrativePersona);
|
||||
let ungranted = affordance_named(&snapshot, "convene");
|
||||
let broken = operations(vec![ComponentOp::Retire {
|
||||
subject: Ref::Existing(SubjectId::issue()),
|
||||
}]);
|
||||
let denied = CommandBody::Act {
|
||||
actor: persona,
|
||||
invocation: speak(ungranted, "Not mine."),
|
||||
};
|
||||
for caller in [
|
||||
CallerId::Principal(owner()),
|
||||
CallerId::Principal(human_principal()),
|
||||
] {
|
||||
for body in [broken.clone(), denied.clone()] {
|
||||
let error = kernel
|
||||
.submit(
|
||||
command(&snapshot, CommandId::new(), caller.clone(), body),
|
||||
&AuthenticatedCaller::fixture(caller.clone()),
|
||||
)
|
||||
.unwrap_err();
|
||||
assert!(matches!(error, KernelError::Unauthorized), "{error:?}");
|
||||
}
|
||||
}
|
||||
// The same commands from Play are refused for what they are.
|
||||
let error = reject_play(&mut kernel, &snapshot, broken);
|
||||
assert!(!error.is_empty());
|
||||
let error = act(&mut kernel, persona, speak(ungranted, "Not mine.")).unwrap_err();
|
||||
assert!(matches!(error, KernelError::AffordanceDenied), "{error:?}");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_world_is_born_active() {
|
||||
let (_directory, path, mut kernel) = world("BornActive");
|
||||
|
|
|
|||
Loading…
Reference in a new issue