hyf

Context-aware query service for Radroots
git clone https://radroots.dev/git/hyf.git
Log | Files | Refs | README | LICENSE

dispatch_observer.mojo (1583B)


      1 # ADR-0027 D47 BP02 — bounded in-memory dispatch observation seam.
      2 #
      3 # The pre-activation guard's zero-dispatch obligation is proven with an
      4 # executed counter at the real pre-dispatch boundary. The observer is threaded
      5 # through the dispatch path as a compile-time type parameter: the production
      6 # daemon instantiates ``NoopDispatchAttemptObserver`` (a compile-time no-op with
      7 # no state and no I/O) and tests instantiate
      8 # ``RecordingDispatchAttemptObserver`` (an ordinary in-memory list owned by the
      9 # test invocation). There is no environment variable, file path, global
     10 # observer, dynamic production switch, durable trace facility or runtime
     11 # dependency, and no observer instance is shared across invocations.
     12 
     13 from std.collections import List
     14 
     15 
     16 trait DispatchAttemptObserver:
     17     """Bounded pre-dispatch boundary observer.
     18 
     19     Implementations must not perform I/O or retain process-global state; the
     20     production implementation is a compile-time no-op.
     21     """
     22 
     23     def record_dispatch_attempt(mut self, capability: String):
     24         ...
     25 
     26 
     27 @fieldwise_init
     28 struct NoopDispatchAttemptObserver(Copyable, DispatchAttemptObserver, Movable):
     29     """Compile-time no-op production observer."""
     30 
     31     def record_dispatch_attempt(mut self, capability: String):
     32         pass
     33 
     34 
     35 @fieldwise_init
     36 struct RecordingDispatchAttemptObserver(DispatchAttemptObserver, Movable):
     37     """Test-owned in-memory observer; never used by the production daemon."""
     38 
     39     var attempts: List[String]
     40 
     41     def record_dispatch_attempt(mut self, capability: String):
     42         self.attempts.append(capability)