@@ -85,17 +85,10 @@ func (co CanonicalOutline) Compile() (Iterator, error) {
8585
8686// compileOutline recursively builds an Iterator tree from an Outline,
8787// looking up each node's CanonicalKey from the provided map.
88- // Filter operations (ID == 0) derive their canonical key on the fly via Serialize().
8988func compileOutline (outline Outline , keys map [OutlineNodeID ]CanonicalKey ) (Iterator , error ) {
90- var key CanonicalKey
91- if isFilterOperation (outline ) {
92- key = outline .Serialize ()
93- } else {
94- var ok bool
95- key , ok = keys [outline .ID ]
96- if ! ok {
97- return nil , spiceerrors .MustBugf ("outline node ID %d not found in CanonicalKeys map - outline must come from a CanonicalOutline" , outline .ID )
98- }
89+ key , ok := keys [outline .ID ]
90+ if ! ok {
91+ return nil , spiceerrors .MustBugf ("outline node ID %d not found in CanonicalKeys map - outline must come from a CanonicalOutline" , outline .ID )
9992 }
10093
10194 // First, recursively compile all subiterators (bottom-up)
@@ -359,14 +352,6 @@ func Decompile(it Iterator) (Outline, error) {
359352 }
360353}
361354
362- // isFilterOperation returns true for Outline nodes that are pure filter
363- // operations and therefore do not have their own canonical representation.
364- // Filter operations are transparent: their canonical key is their child's key.
365- // Currently only CaveatIteratorType qualifies.
366- func isFilterOperation (o Outline ) bool {
367- return o .Type == CaveatIteratorType
368- }
369-
370355type OutlineMutation func (Outline ) Outline
371356
372357// MutateOutline performs a bottom-up traversal of the outline tree, applying
@@ -544,17 +529,9 @@ func caveatCompare(a, b *core.ContextualizedCaveat) int {
544529// Format: <Type>(<Args>)[<Sub1>,<Sub2>,...]
545530// Returns a CanonicalKey wrapping the serialized string.
546531//
547- // Filter operations (e.g. CaveatIteratorType) are transparent: their canonical
548- // key is their child's key, since filters do not affect the set identity .
532+ // CaveatIterator nodes are identified solely by their caveat name, independent
533+ // of their position in the tree. Their subiterators are not included in the key .
549534func (outline Outline ) Serialize () CanonicalKey {
550- // Filter operations are transparent — delegate to child
551- if isFilterOperation (outline ) {
552- if len (outline .SubOutlines ) > 0 {
553- return outline .SubOutlines [0 ].Serialize ()
554- }
555- return CanonicalKey ("" )
556- }
557-
558535 var result strings.Builder
559536
560537 // Add type (single character)
@@ -570,6 +547,12 @@ func (outline Outline) Serialize() CanonicalKey {
570547 }
571548 }
572549
550+ // Caveat nodes are identified solely by their name, independent of
551+ // their position in the tree. Do not include subiterators in the key.
552+ if outline .Type == CaveatIteratorType {
553+ return CanonicalKey (result .String ())
554+ }
555+
573556 // Add subiterators if present
574557 if len (outline .SubOutlines ) > 0 {
575558 result .WriteByte ('[' )
0 commit comments