Skip to content

M9: bounded host event ring + events poll op - #74

Merged
hexuria merged 1 commit into
mainfrom
m9-event-ring
Oct 18, 2026
Merged

hexuria merged 1 commit into
mainfrom
m9-event-ring

Conversation

@hexuria

@hexuria hexuria commented Oct 18, 2026

Copy link
Copy Markdown
Owner

Summary

M9 from the instinct PRD: a bounded, host-owned event ring so agents can
see what the app said happened (log lines, lifecycle notices) without
scraping stderr. Poll-only; push subscription is an explicit non-goal.

  • EventRing — Mutex<VecDeque<AgentEvent>>, cap 1024, monotonic u64
    seq, no clock field (deterministic streams per I5). Eviction sets
    lagged so pollers know they dropped events instead of seeing a gap.
  • AgentHost::event_ring() — defaulted Option method. Hosts without a
    ring fail closed: "events unsupported on this host", never an empty
    list pretending to be a stream.
  • Op::Events {since, limit} — additive on PROTOCOL_VERSION 2;
    hello.features advertises "events" only when the host has a ring.
  • AgentClient::events, gpui-agent events [--since N] [--limit N],
    MCP events tool (ungated — it's a protocol op, not a policy feature).
  • todo-headless pushes one info event per todo.* invoke — the e2e
    fixture proving the app-side bridge recipe.

PRD: expanded docs/plans/2026-10-17-instinct-prd.md §M9 with full
semantics before implementing (was a 3-line stub).

Test plan

  • Ring unit tests: seq monotonicity, since-filter, eviction+lagged,
    limit cap, zero-capacity
  • Dispatch: supported host round-trip, unsupported host error,
    hello advertises events iff ring present
  • CLI e2e (tests/events.rs) + MCP cursor poll
    (tests/mcp_instinct.rs::events_tool_polls_the_ring)
  • cargo test --workspace ×3 configs (default / instinct / jev) — 0 failures
  • cargo fmt --check, cargo clippy --workspace --all-targets ×3 — clean

Generated with Devin

Agents had no way to see what the app itself said happened — log lines,
lifecycle notices, subsystem chatter — without scraping stderr. This adds
a poll-only event stream per the expanded M9 PRD section:

- `EventRing`: Mutex<VecDeque<AgentEvent>>, capacity 1024, monotonic u64
  seq from 1, no clock field (deterministic streams — I5). Past-capacity
  evicts oldest; `lagged` tells pollers they lost events instead of
  silently gapping.
- `AgentHost::event_ring()` — defaulted Option method; existing hosts
  compile unchanged and fail closed with "events unsupported on this
  host" rather than returning an empty list.
- `Op::Events {since, limit}` — additive on PROTOCOL_VERSION 2; `hello.
  features` advertises "events" only when the host supplies a ring.
- `AgentClient::events`, CLI `gpui-agent events`, MCP `events` tool.
- todo-headless pushes an info record per successful `todo.*` invoke —
  the e2e fixture proving the app-side bridge recipe.
- No subscribe/push, no runner/receipt coupling — explicit non-goals.

Tests: ring order/eviction/lagged/zero-capacity, dispatch supported +
unsupported hosts, hello advertisement, CLI e2e, MCP cursor poll.

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@hexuria
hexuria merged commit c6fa227 into main Oct 18, 2026
5 checks passed
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.

2 participants