[docs]classScene(TraversableNode):"""Scene() Container node that groups blocks into a traversable narrative segment. Why ---- Scenes provide the structural scope that blocks, roles, and settings hang from. They also maintain source and sink pointers so container traversal is deterministic once children are materialized. Key Features ------------ * Groups blocks into a shared traversal and namespace scope. * Carries scene-level role and setting declarations. * Owns source/sink cursor pointers used by container traversal. API --- - :attr:`title` stores the authored scene heading. - :attr:`roles` and :attr:`settings` hold scene-scope provider declarations. - :meth:`finalize_container_contract` derives missing source/sink ids from current child order. """title:str=""roles:list[dict[str,Any]]=Field(default_factory=list)settings:list[dict[str,Any]]=Field(default_factory=list)deffinalize_container_contract(self)->None:"""Populate source/sink ids from current child order when absent."""children=list(self.children())ifchildren:ifself.source_idisNone:self.source_id=children[0].uidifself.sink_idisNone:self.sink_id=children[-1].uid