mechaharness.core.events
Queryable structured event log.
A harness is an agent with a finite run. Parent agents share one EventLog
with children and query it (including via tools). This module has no harness
or injector imports.
- class mechaharness.core.events.AgentRef(*, agent_id: str, parent_agent_id: str | None = None, first_ts: datetime, last_ts: datetime, label: str | None = None)[source]
Bases:
BaseModelAn agent observed in the log.
- first_ts: datetime
- last_ts: datetime
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- class mechaharness.core.events.CoreEvent[source]
Bases:
EventTypeBuilt-in MechaHarness events (
core:*).
- class mechaharness.core.events.Event(*, ts: datetime = <factory>, type: str, agent_id: str, run_id: str, parent_agent_id: str | None = None, payload: dict[str, ~typing.Any]=<factory>)[source]
Bases:
BaseModelOne structured log record.
- model_config = {}
Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].
- ts: datetime
- class mechaharness.core.events.EventLog[source]
Bases:
ABCWrite and query structured agent events.
- abstractmethod agents(*, parent_id: str | None = None) list[AgentRef][source]
Agents seen in the log.
parent_idlimits to direct children.
- abstractmethod emit(event: mechaharness.core.events.Event) None[source]
Append one event.
- class mechaharness.core.events.EventType[source]
Bases:
objectNamespaced event identity.
Subclass to add types. The wire form is
namespace:name(for examplecore:agent_start). Intermediate classes setnamespace; leaves setname.
- class mechaharness.core.events.FanoutEventLog(*logs: mechaharness.core.events.EventLog)[source]
Bases:
EventLogEmit to every log; query / agents use the first non-logging store.
- __init__(*logs: mechaharness.core.events.EventLog) None[source]
- agents(*, parent_id: str | None = None) list[AgentRef][source]
Agents seen in the log.
parent_idlimits to direct children.
- emit(event: mechaharness.core.events.Event) None[source]
Append one event.
- class mechaharness.core.events.InMemoryEventLog[source]
Bases:
EventLogList-backed store with agent / run / parent indexes.
- agents(*, parent_id: str | None = None) list[AgentRef][source]
Agents seen in the log.
parent_idlimits to direct children.
- emit(event: mechaharness.core.events.Event) None[source]
Append one event.
- class mechaharness.core.events.LoggingEventLog(logger: Logger | None = None)[source]
Bases:
EventLogWrite adapter: one JSON line per event on
mechaharness.events.Not a store:
query/agentsreturn empty lists.- agents(*, parent_id: str | None = None) list[AgentRef][source]
Agents seen in the log.
parent_idlimits to direct children.
- emit(event: mechaharness.core.events.Event) None[source]
Append one event.
- mechaharness.core.events.default_event_log() FanoutEventLog[source]
In-memory store plus stdlib logging.