Index each beat's caption and enclosing scene slug from the screenplay tree,
keyed by beat id: the join table planCaptionSidecar consults per span.
The walk is depth-first from every root node, children in declaration order,
carrying the nearest scene slug down. A script whose tree is null or
absent, or a tree with no root, yields an empty map, so every span captions
null. A node unreachable from a root is never visited, and a beat id that
appears on two beat nodes keeps the later visit; commit validation refuses
both shapes, so neither reaches a committed script.
Index each beat's caption and enclosing scene slug from the screenplay tree, keyed by beat id: the join table
planCaptionSidecarconsults per span.The walk is depth-first from every root node, children in declaration order, carrying the nearest scene slug down. A script whose
treeis null or absent, or a tree with no root, yields an empty map, so every span captions null. A node unreachable from a root is never visited, and a beat id that appears on two beat nodes keeps the later visit; commit validation refuses both shapes, so neither reaches a committed script.