diff --git a/native/aetherlight/PROVENANCE.md b/native/aetherlight/PROVENANCE.md index ccdd9f276..447f1ad70 100644 --- a/native/aetherlight/PROVENANCE.md +++ b/native/aetherlight/PROVENANCE.md @@ -181,8 +181,6 @@ Kept untouched for AL2b: controllers and `ControllerMode`, consumers `#![allow(dead_code)]` still hides the dead code of a crate with no entry point. What the cut deletes is gone; what remains is part B's: -- Controller lane (AL2b-2b's): `resolve_controller`, `controller_mode`, - `controller_key`. - Authenticated-caller vocabulary: `AuthenticatedCaller::fixture`, `verified_principal`, `verified_play`, and `requires_owner_restart`; id helpers `text` and `nil_for_test`; @@ -308,3 +306,19 @@ count of code readers of `state.events` did not rise (idea - A cross-crate proof that forged opportunities and ids are refused, equivalent to the dropped `tests/external_admission.rs`, against the ABI's surface. - Removal of `#![allow(dead_code)]`. + +## AL2b-2b: controllers go, retirement on the subject + +The subject controller is gone: `ControllerAssignment`, `ControllerId`, +`ControllerMode`, `NewController`, `DecisionScope`, `SubjectDeclaration.controller`, +`Mismatch::UnadmittedController`, `validate_assignment`, the snapshot's controller +fields and `ControllerId::issue`. Retirement is `SubjectState.retired`, and +`is_retired` is its only statement. `affordance_grants` is keyed by `SubjectId`. +`admits_human` is `is_genesis`: it says what the from-nothing lane may build (the +kernel Speak entry and the first subjects), not who may be bound. The schema is +`consumer.v10`; v9 rows are refused at the schema gate, with no migration. + +Not this cut's, and kept: the channel controller (`ChannelRecord.controller`, +`SetController`, `resolve_controller`), which is dialogue +(`dialogue-is-world-action`). An earlier version of this file listed +`resolve_controller` and `controller_key` as AL2b-2b's; that was wrong. diff --git a/native/aetherlight/src/journal.rs b/native/aetherlight/src/journal.rs index 50c44227e..fa4e8303f 100644 --- a/native/aetherlight/src/journal.rs +++ b/native/aetherlight/src/journal.rs @@ -1225,6 +1225,8 @@ mod tests { (COMMIT_ROW, "ghostlight.world_commit.consumer.v6"), (STATE_ROW, "ghostlight.world_state.consumer.v8"), (COMMIT_ROW, "ghostlight.world_commit.consumer.v8"), + (STATE_ROW, "ghostlight.world_state.consumer.v9"), + (COMMIT_ROW, "ghostlight.world_commit.consumer.v9"), ] { let row = CultCacheEnvelope { key: "state".into(), @@ -2390,13 +2392,13 @@ mod custody_tests { /// state row and commit row each on their own: reverting either constant /// to v8 would let its half of the store in. #[test] - fn v8_state_and_commit_rows_are_refused() { + fn v9_state_and_commit_rows_are_refused() { use crate::tests::{act, auth_principal, creation, first_grant, owner, speak}; let directory = tempfile::tempdir().unwrap(); let (mut kernel, _) = WorldKernel::create( directory.path().join("world.cc"), - creation(CommandId::new(), "SchemaV8"), + creation(CommandId::new(), "SchemaV9"), &auth_principal(owner()), ) .unwrap(); @@ -2413,8 +2415,8 @@ mod custody_tests { let state_row = |schema: &str| { envelope(STATE_ROW, schema, kernel.state.world_id.key(), &kernel.state).unwrap() }; - assert_eq!(STATE_SCHEMA, "ghostlight.world_state.consumer.v9"); - assert_eq!(COMMIT_SCHEMA, "ghostlight.world_commit.consumer.v9"); + assert_eq!(STATE_SCHEMA, "ghostlight.world_state.consumer.v10"); + assert_eq!(COMMIT_SCHEMA, "ghostlight.world_commit.consumer.v10"); recover( [commit_rows(COMMIT_SCHEMA), vec![state_row(STATE_SCHEMA)]].concat(), None, @@ -2423,17 +2425,17 @@ mod custody_tests { for (what, rows) in [ ( - "v8 state row", + "v9 state row", [ commit_rows(COMMIT_SCHEMA), - vec![state_row("ghostlight.world_state.consumer.v8")], + vec![state_row("ghostlight.world_state.consumer.v9")], ] .concat(), ), ( - "v8 commit rows", + "v9 commit rows", [ - commit_rows("ghostlight.world_commit.consumer.v8"), + commit_rows("ghostlight.world_commit.consumer.v9"), vec![state_row(STATE_SCHEMA)], ] .concat(), diff --git a/native/aetherlight/src/lib.rs b/native/aetherlight/src/lib.rs index b3ec753b0..94b323244 100644 --- a/native/aetherlight/src/lib.rs +++ b/native/aetherlight/src/lib.rs @@ -103,8 +103,8 @@ use std::path::Path; use thiserror::Error; use uuid::Uuid; -pub const STATE_SCHEMA: &str = "ghostlight.world_state.consumer.v9"; -pub(crate) const COMMIT_SCHEMA: &str = "ghostlight.world_commit.consumer.v9"; +pub const STATE_SCHEMA: &str = "ghostlight.world_state.consumer.v10"; +pub(crate) const COMMIT_SCHEMA: &str = "ghostlight.world_commit.consumer.v10"; /// Compatibility tag derived from [`STATE_SCHEMA`]: the trailing /// `-` pair (e.g. `foundation-v1`). Callers that publish a @@ -12491,6 +12491,64 @@ mod agency_tests { assert_eq!(kernel.snapshot().unwrap().revision, 1); } + /// Retirement is stored once, on the subject, and a live subject's row is + /// the shape it had before the flag existed. + #[test] + fn a_live_subjects_row_is_unchanged_by_the_flag() { + let live = SubjectState { + label: "Walker".into(), + kind: SubjectKind::Person, + import_key: None, + retired: false, + }; + let live_json = serde_json::to_value(&live).unwrap(); + assert!(live_json.get("retired").is_none()); + let retired = SubjectState { retired: true, ..live.clone() }; + let retired_json = serde_json::to_value(&retired).unwrap(); + assert_eq!(retired_json["retired"], true); + assert_eq!(serde_json::from_value::(live_json).unwrap(), live); + assert_eq!(serde_json::from_value::(retired_json).unwrap(), retired); + } + + #[test] + fn a_patch_carrying_a_controller_does_not_decode() { + let Declaration::Subject(declared) = crate::tests::subject("walker", "Walker", SubjectKind::Person) + else { + unreachable!() + }; + let mut json = serde_json::to_value(&declared).unwrap(); + serde_json::from_value::(json.clone()) + .expect("the declaration decodes as built"); + json["controller"] = serde_json::json!({"type": "operational_agent"}); + assert!(serde_json::from_value::(json).is_err()); + } + + /// Retire sets the flag `is_retired` reads, and nothing else retires. + #[test] + fn retirement_lives_on_the_subject() { + let (_directory, path, mut kernel) = world("RetireFlag"); + let snapshot = kernel.snapshot().unwrap(); + let persona = subject_by_label(&kernel.state, "The Witness"); + assert!(!is_retired(&kernel.state, persona)); + submit_play( + &mut kernel, + &snapshot, + operations(vec![ComponentOp::Retire { + subject: Ref::Existing(persona), + }]), + ); + assert!(kernel.state.subjects[&persona].retired); + assert!(is_retired(&kernel.state, persona)); + assert!(!kernel.state.positions.contains_key(&persona)); + assert!(!kernel.state.affordance_grants.contains_key(&persona)); + let after = kernel.snapshot().unwrap(); + assert!(after.subjects.iter().find(|s| s.id == persona).unwrap().retired); + drop(kernel); + let reopened = WorldKernel::open(&path, after.world_id).unwrap(); + assert!(is_retired(&reopened.state, persona)); + assert_eq!(reopened.snapshot().unwrap(), after); + } + #[test] fn retired_tags_do_not_decode() { fn refused(json: &str) {