Skip to content

engine: Observer adapter — passive per-step hook + built-ins (SPEC §8)#30

Merged
fruwe merged 1 commit into
mainfrom
engine-observer
Jul 1, 2026
Merged

engine: Observer adapter — passive per-step hook + built-ins (SPEC §8)#30
fruwe merged 1 commit into
mainfrom
engine-observer

Conversation

@fruwe

@fruwe fruwe commented Jul 1, 2026

Copy link
Copy Markdown
Member

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 }.
  • Per-step record construction is factored into a single _run_one_step helper shared by both loops, so notification is identical and the existing loop semantics are preserved.
  • Built-in observers: JsonlObserver(stream) (one JSON record per line — a drop-in transition log) and CollectingObserver (records to a list). Exported from the top-level package; README note added.

Verify

5 new tests (auto path, manual step path, observer=None no-op, passivity, JSONL output). Full gate: ruff + mypy clean; 169 tests (was 164). No conformance change (Observer is spec-optional).

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.
@fruwe fruwe merged commit c3e9e6f into main Jul 1, 2026
1 check passed
@fruwe fruwe deleted the engine-observer branch July 1, 2026 03:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

engine: Observer adapter — passive per-step hook + built-in observers

1 participant