Adds caller_context per ADR-0063 - #215
Merged
Merged
Conversation
Implements ADR-0063's opaque caller-context slot end to end: - Statifier.Event, Effect.SendDelayed, and Effect.Cancel gain caller_context (term(), default nil); Event.external/2 reads the new :caller_context opt, internal/3 and platform/3 never do. - MachineState gains the transient per-macrostep field with its three writers: handle_event/2 stamps the triggering event's slot, initialize/2 and cancel/1 stamp nil. The two durable-timer effect constructors copy it beside the counters they already read. - Session.Effects' delivered_event/2 and internal_event/1 copy the effect's slot onto the event a scheduled timer later delivers. - Four telemetry events gain a caller_context metadata key: macrostep start/stop and the send_delayed/cancel effect events (ADR-0040 amendment; metadata, never a measurement). - Recording format_version bumps 2 -> 3; version-1/2 blobs decode with caller_context: nil defaulted onto stored events and durable-timer effects. - Docs: opentelemetry.md's session-process caveat now names the field and its read points; durable-timers.md carries the row-data rule; persistence.md notes the bump and the host-term obligation. Refs: st-kahq
This was referenced Aug 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The OTel bridge's handlers run in the session's own GenServer process, so
a sender's trace context is never ambient where a macrostep span opens,
and a durable timer firing hours later has no memory of the trace that
scheduled it. ADR-0063 decided the fix - an opaque
caller_context :: term()the host sets at send time and the library carries without everreading - and sized the implementation onto this bead.
What
caller_context(defaultnil) onStatifier.Event,Effect.SendDelayed, andEffect.Cancel; settable only throughEvent.external/2's opts.%MachineState{}gains the transient per-macrostep field with exactlythree writers (
handle_event/2stamps the triggering event's slot;initialize/2andcancel/1stampnil); the two durable-timereffect constructors copy it beside the counters, so the stamp is the
core's and replay re-mints it byte-identically.
Session.Effects.delivered_event/2/internal_event/1copy theeffect's slot onto the event a scheduled timer later delivers, so an
in-process firing re-enters
handle_event/2carrying the scheduler'scontext.
caller_contextmetadata key (macrostepstart/stop, effect send_delayed/cancel) - the ADR-0040 additive
amendment; the contract table is updated.
Session.Recordingformat version bumps 2 -> 3; version-1/2 blobsdecode with
caller_context: nildefaulted onto stored events anddurable-timer effects, with round-trip and hand-built-envelope tests.
caveat now names the field and its read points, durable-timers.md
documents the row-data-never-key rule, persistence.md notes the bump
and the host-term obligation. Changelog fragment included.
Notes
mix qualitygreen (attested viamix gate.verifypath) andmix quality --profile mergegreen (ADR judge: no findings). Everynew test's sabotage mutation was run and confirmed red, then reverted.
_eventdoesnot surface the slot (spec 5.10.1).
stored timer fires) belongs to statifier_oban's tracker (mirror bead
sob-v28) and is not part of this change.
Closes st-kahq