engine: Observer adapter — passive per-step hook + built-ins (SPEC §8)#30
Merged
Conversation
Host accepts an optional observer callback, invoked once per completed RTC step
(auto and manual) with { instance, event, transition, entered, exited, published,
spawned, faulted }. The per-step record construction is factored into one helper
shared by run_to_quiescence and step, so both paths notify identically; the
observer is purely passive. Add built-in JsonlObserver (a drop-in transition log)
and CollectingObserver, export them, and document usage.
Closes #28.
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.
Closes #28. Implements the Observer specced in fruwehq/harel#28 (§8).
What
Host(observer=…)— an optional passive callback invoked once per completed RTC step, on both the automatic (run_to_quiescence) and manual (step, §14) paths, with{ instance, event, transition, entered, exited, published, spawned, faulted }._run_one_stephelper shared by both loops, so notification is identical and the existing loop semantics are preserved.JsonlObserver(stream)(one JSON record per line — a drop-in transition log) andCollectingObserver(records to a list). Exported from the top-level package; README note added.Verify
5 new tests (auto path, manual
steppath,observer=Noneno-op, passivity, JSONL output). Full gate: ruff + mypy clean; 169 tests (was 164). No conformance change (Observer is spec-optional).