Skip to content

RFC: Continuous Event Transport for AI Coding Agents #20

Description

@huan

Authors

PromptWareOS Core

Abstract

This RFC defines a platform‑agnostic, continuous event transport model that enables AI coding agents to participate as first‑class capability actors in a pure CQRS + Event‑Driven Architecture (EDA) system.

The design preserves CQRS/EDA purity while enabling low‑latency, reactive agent workflows across heterogeneous AI coding agent platforms (wake‑capable, polling‑only, or future systems). It introduces promise‑first semantics, continuous transport sessions, watcher/digestor behavior, and explicit wake signaling—without coupling to any specific agent runtime, UI, or tool execution mechanism.


1. Motivation

Modern AI coding agents are fundamentally turn‑based, while real systems are event‑driven. Naïve integrations force the system to wait for human or agent turns, introducing latency, reducing UX quality, and breaking the mental model of reactive systems.

This RFC resolves that tension by:

  • Making the transport continuous, not the model
  • Treating agents as capability actors under CQRS
  • Defining promise‑first semantics for all operations
  • Allowing hosts to schedule model invocations when actionable events occur

The result is a system that feels real‑time when possible, and degrades gracefully when not.


2. Non‑Goals

This RFC does not:

  • Specify UI behavior or terminal tooling
  • Require any specific AI agent platform features
  • Define concrete scheduling or threading implementations
  • Replace existing PromptWareOS CQRS or transport RFCs

3. Terminology

  • CQRS: Command Query Responsibility Segregation
  • EDA: Event‑Driven Architecture
  • Capability Actor: An addressable actor with a serialized mailbox
  • Session: A continuous transport context
  • Promise‑like: An operation whose result resolves in the future
  • Watcher: A digestor that observes the transport stream
  • BlobPointer: An immutable reference to encrypted, stored payloads

4. Design Principles & Invariants

  1. Everything is an event or derived from events
  2. All operations are promise‑like by default
  3. Commands describe intent; events describe facts
  4. At‑least‑once delivery + idempotent handlers
  5. Strict serialization per capability actor
  6. Single join rule: metadata.causation === request.metadata.id
  7. Transport is continuous; model execution is scheduled
  8. Platform agnosticism is mandatory

5. Session Model

5.1 Session Identity

Each continuous transport context MUST be identified by:

  • metadata.session

metadata.session groups messages belonging to the same transport context. It MUST NOT overload metadata.id or causation fields.

5.2 Session Lifecycle

Sessions follow the PromptWareOS lifecycle:

BOOTING → READY → QUIESCENT → SHUTTING_DOWN → STOPPED

6. Promise Semantics

6.1 Promise‑First Rule

All commands and queries are promise‑like.

There is no synchronous semantic in the protocol. Operations that complete immediately are considered promises resolved immediately.

6.2 Resolution Rules

  • Commands

    • response indicates acceptance or rejection only
    • Terminal resolution MUST occur via events
  • Queries

    • Terminal resolution MUST occur via response

This rule is normative.


7. CQRS Message Semantics

Each message envelope includes:

  • kind: command | query | response | event
  • metadata.id (unique per message)
  • metadata.causation (join rule)
  • metadata.session
  • metadata.origin

No additional join or correlation rules are defined.


8. Capability: System.Shell

8.1 Definition

System.Shell is a capability command representing execution within the system environment. The environment is implementation‑defined and MAY include local, remote, sandboxed, or simulated execution.

8.2 Semantics

  • Always promise‑like
  • Initial response MAY return a handle
  • Output, progress, completion, and failure are delivered as events

No synchronous blocking behavior is defined.


9. Continuous Transport Model

The transport MUST support:

  • Streaming of CQRS envelopes
  • Session‑scoped ordering
  • At‑least‑once delivery

Transport framing (NDJSON, streams, sockets, etc.) is implementation‑defined.


10. Watcher & Digestor Behavior

10.1 Role

A Watcher observes the continuous transport stream and produces digests suitable for agent consumption.

The watcher:

  • Batches messages
  • Prioritizes faults and causation‑linked replies
  • Emits digests instead of raw streams
  • Never issues domain commands

10.2 Compliance

  • L2 compliance REQUIRES watcher‑equivalent behavior
  • L1 MAY omit watcher behavior

11. Wake Semantics

11.1 Agent.Wake

Agent.Wake is a first‑class event signaling that actionable information is available for an agent.

11.2 Actionable Definition

Actionable events include:

  1. Messages causally linked to an outstanding agent request
  2. Faults or execution failures
  3. Explicit decision‑required signals

12. Backpressure & Flow Control

Backpressure MUST be represented via CQRS messages:

  • Credit‑based flow control
  • Queue depth / lag telemetry events

Imperative pausing is prohibited.


13. Security & Trust Model

13.1 Trust Posture

AI agents are treated as trusted capability actors.

13.2 Data Protection

Implementations handling sensitive data MUST:

  • Encrypt payloads at rest
  • Redact secrets before LLM exposure
  • Use BlobPointer references for raw data

14. Compliance Levels

Level Description
L1 Poll‑only, turn‑based
L2 Continuous transport + watcher
L3 Wake‑capable scheduling

15. Extension Points

The following are explicitly extensible:

  • Capability namespaces
  • Event types
  • Wake reasons
  • Flow control strategies

Appendix A: Design Invariants Checklist

  • Promise‑first semantics
  • Event‑based command completion
  • Single causation join rule
  • Session‑scoped transport
  • Watcher for L2

Appendix B: Capability Author Checklist

  • Idempotent handlers
  • No synchronous assumptions
  • Events describe facts
  • Secrets never streamed

Appendix C: Compliance Matrix

See Section 14.


Appendix D: Glossary

  • Promise‑like: Resolution via future messages
  • Watcher: Transport digestor
  • Wake: Scheduling signal

16. Non-Normative Sequence Diagrams

This section is informative, not normative. It illustrates typical flows using the rules defined above.

16.1 Command → Event → Agent.Wake (Promise Resolution via Events)

Agent            Transport / System           Watcher           Host Scheduler
  |                    |                        |                    |
  | Command (System.Shell)                      |                    |
  |------------------->|                        |                    |
  |                    | Response (accepted)    |                    |
  |<-------------------|                        |                    |
  |                    |                        |                    |
  |                    | Event: OutputChunk     |                    |
  |                    |----------------------->|                    |
  |                    | Event: Completed       |                    |
  |                    |----------------------->|                    |
  |                    |                        | Digest + Wake      |
  |                    |                        |------------------->|
  |                    |                        |                    |
  |            (Agent invoked by host scheduler)                     |

Notes:

  • The command is promise-like.
  • Terminal resolution occurs via events.
  • Agent.Wake is derived from watcher policy.

16.2 Query → Response (Immediate Resolution)

Agent            Transport / System
  |                    |
  | Query              |
  |------------------->|
  |                    |
  | Response (result)  |
  |<-------------------|

Notes:

  • Queries resolve via responses.
  • Still promise-like, even if immediate.

16.3 Backpressure via Credit-Based Flow Control

Watcher / Host        Transport
  |                    |
  | Flow.Credit.Grant |
  |------------------->|
  |                    |
  | Event stream (<=N) |
  |<-------------------|
  |                    |

End of RFC

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions