docs(spec): body-level `on` — buffered subscriptions with idle/deadline bounds

Merged
MI
3mo ago
+309-0

Refs #432. This PR changes docs only.

Why

A flow that opens a PR has no way to stay with it: waking on review comments or CI, fixing, and stopping when the PR is merged, closed, or ready. on is already a resident verb (decision 13), but the spec doesn't say:

  • how a running body subscribes to events after it starts,
  • what happens to events that arrive while a step is running,
  • how a wait ends when events stop.

There is never a "no more feedback" signal. A flow ends on provider state and uses time only as a backstop.

What

  • New docs/EVENT-AWAIT.md. It covers:
    • the surface: f.on(...) inside a body, next() returning events | idle | deadline, and settle / idle / deadline / includeSelf
    • eight semantic laws: wakes are level-triggered, buffered, deduplicated, and filter the run's own events
    • additive kernel entries (subscription.opened / subscription.closed, a stream-backed wait.event extension, enforced wait timers)
    • the Cloud router contract, crash-injection acceptance tests, and open questions
  • Pointers to it from SURFACE.md §6, kernel/DESIGN.md §1.4, and RFC-0001 §7 open questions.
  • Current state recorded in kernel/DESIGN.md §1.4: nothing produces wait.event yet, and timeout_at_ms isn't enforced.

It adds no new step kind or verb, so the kernel vocabulary stays closed.

Review focus

  • Should idle and deadline both be required (unbounded_subscription at preflight)?
  • Report timeouts as timeout plus result.timeout, rather than adding new completion reasons?
  • Reuse the trigger's recursive-subset pattern for subscriptions?

🤖 Generated with Claude Code


[!NOTE]
Low Risk
Documentation-only; no runtime, auth, or data-path code changes. Future implementation of the spec would touch kernel and Cloud routing.

Overview
Adds docs/EVENT-AWAIT.md, a proposed spec for using resident on inside a running flow body (not only as an entry trigger). It defines durable buffered subscriptions with activity.next() waking on events, idle, deadline, or overflow, required idle/deadline bounds (flows check → unbounded_subscription), and options like settle and includeSelf.

The doc also spells out semantic laws (level-triggered re-reads, no loss while open, self-event filtering), additive kernel journal (subscription.opened/closed, stream-backed wait.event, enforced wait timers), the Cloud router handshake, and a 15-point crash-injection acceptance list. It records today’s gaps (no wait.event producer, dropped events while busy, unenforced timeouts, no body on in surface).

Cross-links: SURFACE.md §6 open questions, RFC-0001 §7 (“Ending a resident wait”), and kernel/DESIGN.md §1.4 (proposed extension + current-state note). No new kernel verbs — vocabulary stays closed per decision 13.

Reviewed by Cursor Bugbot for commit 5fa199cc3929d45fb64e9f764bf3729ad390cca3. Bugbot is set up for automated code reviews on this repo. Configure here.