Module: Protege::Subscribers::Tracing
Overview
The tracing subscriber — the one place that knows the Protege::Trace table exists. Subscribes to
InferenceGeneratedEvent (emitted once per turn by the Harness, only when config.tracing is on)
and snapshots the turn into a durable, self-contained row for later fine-tuning. A peer of
Subscribers::HookDispatcher and Subscribers::IntrospectionBroadcaster, installed at boot.
Kept deliberately decoupled: the Harness gates whether the event fires; this module gates nothing
and simply persists what arrives. Delete the install! call and tracing disappears with the
Harness untouched. Writing is best-effort — any failure is logged and swallowed, never
propagated, so a tracing hiccup can't abort an inference run (the reply may already have been sent).
A trace records only what affects training: the wire request and response (each already
serialized by the value object's own #to_wire, the same bytes the API exchange uses) and the
inference settings (+model+ + settings). No persona/provider identity is stored, and this module
does no serialization of its own — it just persists what the event carries.
Instance Method Summary collapse
-
#install! ⇒ void
Subscribe the tracing recorder to the per-turn event — the subscriber's
install!contract. -
#reset! ⇒ void
Detach the subscription — the subscriber's
reset!contract, for boot re-wiring and tests.
Instance Method Details
#install! ⇒ void
This method returns an undefined value.
Subscribe the tracing recorder to the per-turn event — the subscriber's install! contract.
Idempotent; called once at boot from the engine's after_initialize.
29 30 31 32 33 |
# File 'lib/protege/subscribers/tracing.rb', line 29 def install! return if @handle @handle = InferenceGeneratedEvent.subscribe { |event| record(event) } end |
#reset! ⇒ void
This method returns an undefined value.
Detach the subscription — the subscriber's reset! contract, for boot re-wiring and tests.
38 39 40 41 42 43 |
# File 'lib/protege/subscribers/tracing.rb', line 38 def reset! return unless @handle ActiveSupport::Notifications.unsubscribe(@handle) @handle = nil end |