Scenarios

Harmovela Integration Scenarios

Three end-to-end scenarios demonstrating Harmovela's coordination dimensions working together.

---

1. Async Task Orchestration

Narrative: An autonomous agent submits a long-running tool task (e.g. code analysis across a large repository), receives incremental progress events and a final completion event, and may cancel the task mid-flight.

Coordination Dimensions: Task, Delegation

Interaction Steps

StepActorActionEvent Types
1AgentSubmits a task via publishtask.submitted
2RuntimeAcknowledges and enqueues the tasktask.accepted
3WorkerPicks up the task and starts processingtask.started
4WorkerReports progress periodicallytask.progress
5WorkerCompletes the task with a resulttask.completed
5aAgent(optional) Sends cancellation requesttask.cancelled

Code References

FileDescription
examples/quickstart/runtime-embed.*Minimal in-process runtime: create service, subscribe, publish, receive task events
examples/service-client/emit-subscribe.jsWebSocket client: emit a task event and subscribe to receive it
examples/service-client/http-subscribe.jsHTTP API client: create subscription, publish event, long-poll for delivery

Expected Output

The quickstart runtime-embed example produces:

received task.submitted evt_embed

The service-client examples produce:

received task.submitted evt_ws_example
received evt_http

Related Specifications

---

2. Context and Memory Coordination

Narrative: A memory system emits fact changes (additions, invalidations) and retrieval results while a context provider signals context invalidations (e.g. user navigated to a new page). An agent subscriber holds active subscriptions to both memory.* and context.* events and reacts as they arrive.

Coordination Dimensions: Event, State, Context / Memory

Interaction Steps

StepActorActionEvent Types
1AgentOpens a session and subscribes to memory.* and context.*subscription.requestedsubscription.ready
2Context ProviderSignals that the current context is invalidatedcontext.invalidated
3Memory SystemAdds a new fact with confidence scorememory.fact.added
4Context ProviderReports that a new snapshot is readycontext.snapshot.ready
5Memory SystemReturns results for a retrieval querymemory.retrieval.ready
6Non-matching SourceSends an event the agent is NOT subscribed to*(rejected — no matching subscription)*
7Memory SystemInvalidates a previously recorded factmemory.fact.invalidated
8AgentCloses the sessionsession.closed

Code References

FileDescription
examples/scenarios/agent-subscriber.jsAgent subscribes to memory + context events, processes incoming events, handles rejection for unsubscribed types
examples/scenarios/memory-producer.jsMemory system produces fact, retrieval, preference, and invalidation events, routes them via subscription matching

Expected Output

Agent subscriber output (abridged):

=== Agent Subscriber Demo ===
[agent] Opening session...
  ← session.ready
[agent] Subscribing to memory.* + context.* ...
  ← subscription.ready sub_memory_context
[agent] Processing incoming events...
  [ack] context.invalidated → user navigated to new page
  [ack] memory.fact.added → fact_101
  [ack] context.snapshot.ready → /results
  [reject] task.progress — subscription filter mismatch
  [ack] memory.retrieval.ready → Harmovela events
[agent] Closing session...
  ← session.closed

Memory producer output (abridged):

=== Memory Event Producer Demo ===
[agent] Subscribes to memory.* events for conv_demo
[memory] Emitting 5 memory events...
  [send] memory.fact.added
  [send] memory.preference.updated
  [send] memory.summary.ready
  [send] memory.fact.invalidated
  [send] memory.retrieval.ready
=== Events Delivered ===
  [memory.fact.added] fact_001
  [memory.preference.updated] response_style
  ...

Related Specifications

---

3. MCP Bridge with Async Feedback

Narrative: A synchronous MCP tools/call request arrives at the bridge. The bridge delegates the work to an async Harmovela task handler, returns an MCP accepted response immediately, and emits task.submitted, task.started, and task.completed lifecycle events through the transport as the work progresses — all within the same process.

Coordination Dimensions: Event, Task, Recovery

Interaction Steps

StepActorActionWire
1MCP ClientCalls tools/call for async tool "build"MCP request (JSON-RPC 2.0)
2McpBridgeRegisters the tool via asyncToolHandler, creates a task trackerInternal
3McpBridgeEmits task.submitted lifecycle eventHarmovela transport
4McpBridgeEmits task.started lifecycle eventHarmovela transport
5Tool HandlerExecutes the work function (e.g. produces app.bin artifact)Internal
6McpBridgeEmits task.completed with result payloadHarmovela transport
7MCP ClientReceives accepted response with content (artifact, task_id)MCP response

The MCP response is returned synchronously, while the full lifecycle event stream is observable through the transport for downstream consumers (dashboards, audit logs, downstream agents).

Code References

FileDescription
examples/mcp-bridge/async-tool.*Registers an async "build" tool, calls it, observes lifecycle events across all 4 languages

Expected Output

tools/call response: [{"type":"text","text":"{\"artifact\":\"app.bin\",\"task_id\":\"task_demo\"}"}]
lifecycle events: task.submitted → task.started → task.completed

Related Specifications