From a0f22c88d54d351b060c2d0d9f0a8cbf5f412ba2 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 29 Nov 2026 15:02:23 +0000 Subject: enstate: --migrate, renames both ways, kept entries What a generation sees of a snapshot accepted under another schema: same name and type, renamedFrom, a rename in the stored schema read backwards, and entries kept, with their types, in the snapshot's kept/. Plans start from what is seen, and store it under the running schema; a generation change rewrites no snapshot. --migrate (and --dry-run) says what each channel sees, refuses for required slots nothing fills, puts the views in place and runs their reactions; --materialize and --status go by what is seen, too. A view made from an unfilled required slot isn't there. The rollback cases of migrations.md that need no converters or steps are tests. --- src/view.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/view.rs') diff --git a/src/view.rs b/src/view.rs index b7bab6c..bd4b8f5 100644 --- a/src/view.rs +++ b/src/view.rs @@ -17,8 +17,9 @@ use crate::scratch::Scratch; /// would be, the others as they are. pub type Entries<'a> = BTreeMap<&'a str, &'a Content>; -/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if it -/// is an entry's own and that entry isn't there. +/// Renders the view `name` from `entries` into scratch below `scratch`; nothing if a +/// required slot it is made from is unfilled, or it is an entry's own and that entry +/// isn't there. pub fn render( schema: &Schema, name: &str, @@ -31,6 +32,13 @@ pub fn render( .get(address.channel.as_str()) .and_then(|content| content.get(&address.slot)) }; + // A view made from a required slot that is unfilled isn't there (docs/design.md, + // section 7). + if view.from.iter().any(|address| { + schema.slot(address).is_some_and(|slot| slot.required) && entry(address).is_none() + }) { + return Ok(None); + } match &view.renderer { None => { let address = &view.from[0]; -- cgit v1.3.1