⚙️ CAIRO RUNE DIFFICULTY: Apprentice Structural

The Decorator

Adding dynamic enchantments to STARK traces.

✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Decorator
ARCANUM SCHOOL: Enchantment // Augmentation
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CAIRO PATTERN //
trait ITrace { fn execute(self: @TraceBase) -> felt252; }
#[derive(Copy, Drop)]
struct TraceBase {}
impl BaseImpl of ITrace { fn execute(self: @TraceBase) -> felt252 { 'base' } }

trait IDecorator { fn execute_decorated(self: @TraceDecorator) -> felt252; }
#[derive(Copy, Drop)]
struct TraceDecorator { inner: TraceBase }
impl DecoratorImpl of IDecorator {
    fn execute_decorated(self: @TraceDecorator) -> felt252 {
        self.inner.execute() + 'extra_magic'
    }
}

Wrap traces in layers of arcane modifiers without altering their fundamental structure.

Runic Tags: #cairo #design-pattern #decorator