Aetherlight AL2b-2b: schema consumer.v10, v9 refused; pins and PROVENANCE

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
soul 2026-11-20 01:28:06 +01:00
commit 39c50acfcd
3 changed files with 86 additions and 12 deletions

View file

@ -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(),

View file

@ -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
/// `<family>-<version>` 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::<SubjectState>(live_json).unwrap(), live);
assert_eq!(serde_json::from_value::<SubjectState>(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::<SubjectDeclaration>(json.clone())
.expect("the declaration decodes as built");
json["controller"] = serde_json::json!({"type": "operational_agent"});
assert!(serde_json::from_value::<SubjectDeclaration>(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<T: serde::de::DeserializeOwned>(json: &str) {