The Observer of the Astral Web
Define a one-to-many cosmic dependency where all astral nodes are notified when the locus changes.
✧ GANG OF FOUR LINEAGE & ARCANUM ✧
GOF DESIGN PATTERN: Observer
ARCANUM SCHOOL: Divination // Temporal Logic
SCRIBE / ARCHON: Joshua Edward McLaughlin Cox
CANONICAL REGISTRATION:
// CODEX INCANTATION //
---- MODULE Observer ----
EXTENDS Naturals, FiniteSets
CONSTANTS Observers
VARIABLES subjectState, notifiedObservers
Init ==
/\ subjectState = 0
/\ notifiedObservers = Observers
UpdateSubject(val) ==
/\ subjectState' = val
/\ notifiedObservers' = {}
NotifyObserver(obs) ==
/\ obs \notin notifiedObservers
/\ notifiedObservers' = notifiedObservers \union {obs}
/\ UNCHANGED subjectState
Next ==
\/ \E v \in 1..5 : UpdateSubject(v)
\/ \E o \in Observers : NotifyObserver(o)
Spec == Init /\ [][Next]_<<subjectState, notifiedObservers>>
Liveness == \A o \in Observers : []<>(o \in notifiedObservers)
====
The Astral Web vibrates across dimensions. The Observer pattern ensures that when the subjectState shifts, a wave of updates propagates to all Observers. TLA+ proves the powerful Liveness property: no matter the non-deterministic scheduling, eventually ([]<>), every observer will feel the echo of the shift.
Runic Tags:
#tla
#pub-sub
#temporal-divination
#behavioral